Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFont and QFontMetrics : which font standard?
Forum Updated to NodeBB v4.3 + New Features

QFont and QFontMetrics : which font standard?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Katlin
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved