[Interest] Font measuring inconsistency between platforms in Qt5? Or, how best to draw characters with QPainter.

Christoph Feck christoph at maxiom.de
Sun Dec 29 18:36:16 CET 2013


On Sunday 29 December 2013 18:16:29 George Tasopoulos wrote:
> QFont font("Liberation Mono", 18, QFont::Normal, false);
> QFontMetrics metrics(font);
> int x = metrics.height();
> 
> On Windows x equals 27, which seems to be the correct value, but on
> Linux it equals 28.

The (pixel) height of the font is determined by DPI of the display, so 
it is correct that on different systems you get different results for 
the font metrics. After all, that's the reason the QFontMetrics class 
is provided, so that you can adapt to the resulting metrics.

-- 
Christoph Feck
http://kdepepo.wordpress.com/
KDE Quality Team
openSUSE Review Team



More information about the Interest mailing list