mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-14 15:14:49 -04:00
Improved font positioning in Qt backend
This commit is contained in:
parent
656c8132a8
commit
ff332335ea
1 changed files with 6 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "qzint.h"
|
#include "qzint.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
|
||||||
namespace Zint {
|
namespace Zint {
|
||||||
static const char* fontstyle = "Arial";
|
static const char* fontstyle = "Arial";
|
||||||
|
@ -388,8 +389,12 @@ namespace Zint {
|
||||||
if (string) {
|
if (string) {
|
||||||
painter.setFont(fontLarge);
|
painter.setFont(fontLarge);
|
||||||
}
|
}
|
||||||
|
QFontMetrics fm(fontLarge);
|
||||||
while (string) {
|
while (string) {
|
||||||
painter.drawText(0.0, string->y, m_zintSymbol->vector->width, 7, Qt::AlignCenter, QString::fromUtf8((const char *) string->text, -1));
|
QString content = QString::fromUtf8((const char *) string->text, -1);
|
||||||
|
int width = fm.width(content, -1);
|
||||||
|
int height = fm.height();
|
||||||
|
painter.drawText(string->x - (width / 2.0), string->y - height, width, height, Qt::AlignHCenter | Qt::AlignBottom, content);
|
||||||
string = string->next;
|
string = string->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue