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

Tomasz Olszak olszak.tomasz at gmail.com
Thu Oct 18 07:14:13 CEST 2018


Ok,
I just thought that knowing capital letter height I can calculate correct
font pixel size but seems using font metrics and iteration over pixel sizes
is the only option. Thank you all for help!

czw., 18 paź 2018, 01:04 użytkownik Allan Sandfeld Jensen <kde at carewolf.com>
napisał:

> 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
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181018/f167b31a/attachment.html>


More information about the Development mailing list