[Qt-interest] QFont size when printing/creating PDF

Vinicius Jarina viniciusjarina at gmail.com
Mon Jun 28 07:36:49 CEST 2010


Hi

I am writing a application that should print some output or create a PDF
with this same output, and the PDF should be exactly in the same metrics of
the printed output.

This is already done, scaling any output scaling by 72dpi, like this

QSizeF dpiSize(dev->logicalDpiX(),dev->logicalDpiY());

double dScaleX = dpiSize.width() / 72.0;
double dScaleY = dpiSize.height()/ 72.0;

painter.scale(dScaleX, dScaleY);

But, when I try to paint a text. Using any QFont the size in the printer and
in the PDF dont match :(

Like.

QFont arialFont("Arial", 36, QFont::Normal);

pen.setColor(Qt::black);
pen.setWidth(2);

painter->setPen(pen);
// Primitive output match the same size in printer and in pdf
painter->drawRect(QRect(100,100,100,100));
painter->drawEllipse(QRect(500,600,100,200));
painter->drawEllipse(QRect(300,500,300,200));
// the text output dont
painter->setFont(serifFont);
painter->drawText(QPoint(10,400),  "The quick brown");

Am I doing something wrong? scale doesn't work for fonts? should I create
QFont using the QPaintDevice parameter?

Thanks

Vinicius Jarina.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100628/4986b3fc/attachment.html 


More information about the Qt-interest-old mailing list