[Development] Why on Linux using FreeType engine fonts are rendered in 72 dpi instead of Screen DPI?

Allan Sandfeld Jensen kde at carewolf.com
Thu Oct 18 01:04:11 CEST 2018


On Donnerstag, 18. Oktober 2018 00:58:14 CEST Allan Sandfeld Jensen wrote:
> On Mittwoch, 17. Oktober 2018 22:11:38 CEST Tomasz Olszak wrote:
> > Ok,
> > It's a lot more clear. Thank you for explanation!
> > 
> > I used default font with pixel size 100 and according to FontMetrics:
> > 1. family: "Sans Serif"
> > 2. pointSize: 75
> > 3. pixelSize: 100
> > 4. ascent 93
> > 5. descent: 24
> > 6. height: 117
> > 7. leading -1
> > 
> > So how ascent, descent, leading is related to 100. How can I calculate
> > font.pixelSiize knowing that capital letter height is 100. By trial
> > and errors the font with pixel size = 137 and ascent = 129 have
> > capital letter(without accent) of 100 pixel height.
> > Is it a way to determin font.pixelSize if we want the non accent
> > capilat letter to be e.g 100px? Or should I just iterate over pixel
> > sizes and calculate using fontMetrics and tightBoundingRect for
> > capitalized letter without accent?
> 
> You should read the capHeight of the font. I think QFontMetrics can give you
> that (https://doc.qt.io/qt-5/qfontmetrics.html#capHeight), though I am not
> sure if there are QML bindings for that. In any case capital latin letters
> are generally all the same height, so you could probably just measure the
> height of H or M.
> 
See also https://en.wikipedia.org/wiki/Typeface#Font_metrics





More information about the Development mailing list