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 <k...@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@qt-project.org > http://lists.qt-project.org/mailman/listinfo/development >
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development