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

Font Substitution Causes Text Position Shift When Drawing with QPicture in Qt

XMLWordPrintable

    • macOS, Windows

      There can be cases where different results are obtained between the following a and b.

      a) Drawing text directly on a QPainter object using QPainter::drawText()

      b) Drawing text inside another QPicture object using QPainter::drawText(), and then drawing that QPicture onto the QPainter object with drawPicture().

      Under the following conditions, when using method b, the text is drawn shifted from its original position (see CooperBlack_Bravura_mac.png, CooperBlack_Bravura_windows.png) :

      • A substitute font is set for the font used in the text (default font).
      • The text contains a character for which the default font has no glyph, so the substitute font is used.

       

      This issue has been reproduced on Mac OS 14 and Windows 11.

       

      Reproduction steps:

      1. Ensure the 'Cooper Black' font is installed in your environment.
      2. Install the attached 'Bravura' font (from Dorico application, and freely available here: https://github.com/steinbergmedia/bravura )
      3. Build and run the attached 'qpicture-font-substitution-test' app in Qt Creator.
      4. Observe that the 'musical notes' symbol (unicode 0x266B) appears at a different position relative to the line when drawn directly with QPainter::drawText at the top, and when drawn via QPicture at the bottom.

       

      Additional note:

      • The font metrics checked on Windows 11 for Cooper Black and Bravura were as follows.

       

      default font family: "Cooper"
      default font pointSize: 64
      font metrics:
        ascent 78
        descent 19
        height 97
        lineSpacing 97
        lineWidth 11
        overlinePos 79
        underlinePos 4
      
      substitute font family: "Bravura"
      substitute font pointSize: 64
      font metrics:
        ascent 171
        descent 171
        height 342
        lineSpacing 342
        lineWidth 4
        overlinePos 172
        underlinePos 2 

       

       

      • The issue was not reproduced when a different font, which has a glyph for unicode 0x266B, was used as the substitute (e.g. "Yu Gothic UI", see CooperBlack_YuGothicUI_windows.png) .

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            hitoshiito Hitoshi Ito
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes