mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Improved font positioning in Qt backend
This commit is contained in:
parent
656c8132a8
commit
ff332335ea
@ -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…
Reference in New Issue
Block a user