[Qgis-developer] Fonts in composer
Radim Blazek
radim.blazek at gmail.com
Thu May 18 08:43:00 EDT 2006
Heureka (maybe)!
Because Qt4 QPainter supports floating point numbers I could
remove QgsComposition::mScale (set to 1 for now).
Consequently the font scaling factor QgsComposition::psFontScaleFactor
became wrong. I tried to fix the problem with scaling again
and hopefully I found solution, basicaly:
QFont font;
font.setPointSize ( size );
QFontMetrics metrics ( font );
if ( plotStyle() == QgsComposition::Postscript )
{
font.setPointSizeF ( metrics.ascent() * 72.0 /
mComposition->resolution() );
}
painter.setFont ( font );
painter.drawText ( x, y, text );
That means the size of font in Postscript must be set to metrics.ascent()
of original font size.
I tested on Linux with many fonts and different sizes and the font height
seems to be almost always correct and text length is mostly correct.
Tom, could you test on Mac?
Radim
More information about the Qgis-developer
mailing list