Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-107557

The font.pointSize property behaves in an unexpected way.

    XMLWordPrintable

Details

    Description

      Hello,

      I encounter some strange behaviour while using the point size property of fonts in a QML application. The font QML type mentions it has a "point size", but does not define how it behaves. The font.pointSize property of the Text QML component is not really defined either since it does not explain what a point is. However, the font.pixelSize property of Text does it indirectly :

      Sets the font size in pixels.

      Using this function makes the font device dependent. Use pointSize to set the size of the font in a device independent manner.

      Then they are a lot of various comments, old and new, relevant or not, on forums about this notion on the Internet. But it seems to me that your official documentation is a bit scarce, whereas it sould be the fisrt and authoritative source of information, instead of the Internet hearsay. Hence a first part of my request is to please add information or links regarding what a point size is in these places of the documentation.

      That being said, I currently understand pointSize as being a unit that measures the same physical size on each screen, and I make this assumption in the following.

      I have created a small QML application (the corresponding main.qml is attached) which displays a rectangle whose dimensions are displayed (I'm not sure which unit this is) and a Text component with a point size of 20.

      I'm attaching a picture that demonstrates how much size it takes on my development PC screen. I'm also attaching a screenshot taken on a phone (a Xiaomi Mi A1 running Android, nothing fancy as far as I know). This time I have added the measurement information as orange annotations over the screenshot.

      As you can see, this 20-point text measures about 120mm on the PC screen and 62mm on the phone, which makes a ratio of about 1.75, very far from the expected value of 1.

      The ratio between the rectangle sizes is also diferent :

      Platform point width physical width (mm)
      PC 480 130
      Phone 360 68

      This gives a ratio of (130 / 480) / (68 / 360) = 1.43, which is different both from the first one and 1.0.

      It seems to me that, at least for the font's point size (I'm not sure whever the Rectangle width is in pixels or points?), the physical dimension of my application components should be identical on all platforms.

      Could you please fix this if this is a bug, or else explain me what this API does or how it is supposed to be used properly?

      Attachments

        1. Android screenshot point size.png
          Android screenshot point size.png
          100 kB
        2. IMG_20221011_164754.jpg
          IMG_20221011_164754.jpg
          5.69 MB
        3. main.qml
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            graslany Yves Grasland
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes