[Qt-interest] Qt does not provide a way to get a font's "em" size?

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Thu Mar 4 15:56:01 CET 2010


You could try 

http://doc.trolltech.com/4.6/qfontmetrics.html#width-2

QFontMetrics fm(...);
QChar m('M');
int em=fm.width(m);

should be close enough according to the definition on
http://en.wikipedia.org/wiki/Em_%28typography%29

cheers, ulf

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Nikos Chantziaras
> Sent: Thursday, March 04, 2010 3:02 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Qt does not provide a way to get a font's "em"
> size?
> 
> I need to get the "em" size of fonts.  This is a design property of
> scalable fonts.  QFontInfo and QFontMetrics don't seem to offer this
> information and I would have to use FreeType directly to query it
> (QFont::freetypeFace()).  That's not a good solution here since the
> application needs to stay cross platform and still be able to get the
> em
> size.
> 
> Is there any portable solution within Qt to get to that information?
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list