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

Text: add effectiveFontPixelSize/effectiveFontPointSize

XMLWordPrintable

    • 659d5202f915b84bd22b618b0696bbe68ab4b6b0

      With the following example

      Text {
          width: ...
          height: ...
          fontSizeMode: Text.Fit
          font.pixelSize: 100
      }
      

      there's no way of knowing what the actual font size used is. This feature would be useful when you want another Text item that has the same font size as the calculated one. For example, see the attached picture. Each block is a Text item with its width and height set (e.g. in a row). The "italic" and "bold" text has different styling/font family and may even be animated, so it can't be a part of the same Text item. Currently there's no way to match the "italic" and "bold" font sizes to the "Normal text".

      The code would look something like this:

      Row {
          Text {
              id: normalText
              text: "normalText"
              width: ...
              height: ...
              fontSizeMode: Text.Fit
              font.pixelSize: 100
          }
      
          Text {
              text: "italic"
              width: ...
              height: ...
              font.family: "Some Font"
              font.pixelSize: normalText.effectiveFontPixelSize
           }
      
          Text {
              text: "bold"
              width: ...
              height: ...
              font.family: "Some Other Font"
              font.pixelSize: normalText.effectiveFontPixelSize
           }
      }
      

        1. font.png
          6 kB
          Mitch Curtis
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes