QFont and QFontMetrics : which font standard?
I am working on a small project for which I need accurate font metrics calculations.
As nothing was working as expected, I have tried to print out some font metrics values and measure by hand the output text to see it the numbers are right.
The numbers seem to be wrong. For example, for a 24 px font set using font.pixelSize, I get ascent=23, descent=8, leading=0 (!this should be in fact 5) pointSize=18.
By measuring the text in Photoshop, none of the numbers are right.
So my question is: which standards do the font libraries use? Can I find somewhere a schematic for it, for example like this one : https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png ?
Going a bit deep under the hood, I'd recommend bringing that question to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.
My guess is that it is highly platform and configuration dependent. Qt uses plethora of methods to draw text depending on what is available and what hints were provided. For example I just tested it on Windows with 24px default font and it's pretty much like in the picture you posted with these values pixel perfect: ascent 24, descent 5, leading 0, height 29.
As for the leading, remember that some letters can have accents eg. ŚĆŻ etc. so if you test only with english letters then this 5px gap might be the space reserved for accents. This seems to be counted as part of the ascent and not leading.