I am creating a custom label and want it to have a 13 pixel high text and setting label's max height to 14.
textFont.setFamily("Frutiger LT Com 55 Roman");
textFont.setPixelSize(13);
setFont(textFont);
QFontMetrics fm(this->font());
QFontInfo fi(this->font());
qDebug()<<"QFontMetrics"<<fm.height()<<fm.xHeight( )<<fm.ascent()<<fm.descent();
qDebug()<<"QFontInfo"<<fi.exactMatch()<<fi.family( )<<fi.pixelSize();
This is what I get
QFontMetrics 16 3 13 3
QFontInfo true "Frutiger LT Com 55 Roman" 13
Why am I getting height as "16" when I am setting pixelSize as "13"? And because of this text on my label is getting clipped from bottom (Vertically center aligned).
QFontMetrics "height()" definition says height=ascent+descent+1(for baseline). But as you can see above ascent=13, descent=3 and height=16. This contradicts "height()" function definition.
Bookmarks