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

QTextDocument draws corrupted fonts on macOS in certain cases

    XMLWordPrintable

Details

    • macOS
    • cdd7163c60 (qt/qtbase/dev) cdd7163c60 (qt/tqtc-qtbase/dev)

    Description

      The text is drawn corrupted in certain circumstance.

      It appears the problem occurs when:

      • QTextDocument based text
      • The font is styled as bold
      • The font has no explicit bold typeface installed (for example Geneva)
      • The painter drawing the font is scaled smaller (less than 1.0 scale)
      • macOS (Windows is fine)

      Here's part of code

          QTextDocument doc;
          {
              QTextCursor cursor(&doc);
              QTextCharFormat qtf;
              QFont myFont("Geneva");
              myFont.setPixelSize(200);
              myFont.setStyleStrategy(QFont::NoAntiali
              qtf.setForeground(QColor(0, 0, 0));
      
              myFont.setBold(true);
              qtf.setFont(myFont);
              cursor.insertText("Bold Geneva\n", qtf);
              ....
           }
          
          QImage pic(600, 400, QImage::Format_ARGB32_Premultiplied);
          pic.fill(QColor(255, 255, 255));
          {
              // approx 100% size
              QPainter painter(&pic);
              painter.translate(0, 50);
              painter.scale(0.25, 0.25);
              doc.drawContents(&painter);
          }
      
          pic.save("/Users/qtsupport/test_scaled.png");
      

      How to reproduce
      1. Use attached project qtbug103215.zip
      2. Modify the file path to your own in main.cpp

      pic.save("/Users/qtsupport/test_scaled.png");
      

      3. Build and run the application
      4. Open the created "test_scaled.png"

      Result

      If the font has no installed bold typeface, it may not expect bold to appear perfectly.
      However, it should not draw corrupted.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            nagrohn Nahomi Gröhn (Inactive)
            Votes:
            12 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes