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

QPainter::drawText() with QPainter::scale() can produce bad kerning and/or aliasing

    XMLWordPrintable

Details

    • Windows

    Description

      See attached animations, taken with the attached sample project.

      • 1080p-100pct-qt5.gif: Good anti-aliasing, poor kerning: "sit" has particularly big gaps
      • 1080p-100pct-qt6.gif: Good anti-aliasing, poor kerning: "sit" has particularly big gaps
      • 1080p-125pct-qt5.gif: Good anti-aliasing, good kerning
      • 1080p-125pct-qt6.gif: Bad aliasing, good kerning
      • 1080p-125pct-qt6-rounded.gif: Good anti-aliasing, good kerning

      All of the animations were taken at 1080p resolution, with different variables:

      • Qt version (Qt 5.15.2 or Qt 6.2.2)
      • OS scaling (100% scaling or 125% scaling)
      • Scale factor rounding policy (The last case has GuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round) enabled; all others don't)

       

      Summary

      • 100% scaling produces worse kerning than 125% scaling in both Qt 5 and 6
      • Qt 6 has bad aliasing at 125% scaling with default settings. Workaround: apply QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round)

       

      Further comments

      The customer reports that only Windows seems to be affected, but it's noticeable on a variety of display hardware. Higher screen resolutions and higher DPIs make the problem less noticeable. The problem also affects QPDFWriter, not just on-screen paint devices (see attached Qt5.pdf and Qt6.pdf, produced using the attached QTBUG-100356_v2.zip)

      Edit: The v2 project adds PDF printing code

       

      Changing font size instead of scaling does produce better results, but the customer uses QPainter::scale() for complex use cases, such as exporting HTML (via QTextDocument) to a printer or a PDF file. Elements other than text (e.g. tables, images) all need to be scaled the same way, so simply changing the font size is not a solution.

      Attachments

        1. 1080p-100pct-qt5.gif
          1080p-100pct-qt5.gif
          135 kB
        2. 1080p-100pct-qt6.gif
          1080p-100pct-qt6.gif
          128 kB
        3. 1080p-125pct-qt5.gif
          1080p-125pct-qt5.gif
          151 kB
        4. 1080p-125pct-qt6.gif
          1080p-125pct-qt6.gif
          157 kB
        5. 1080p-125pct-qt6-rounded.gif
          1080p-125pct-qt6-rounded.gif
          147 kB
        6. Qt5.pdf
          12 kB
        7. Qt6.pdf
          12 kB
        8. QTBUG-100356_v2.zip
          3 kB
        9. QTBUG-100356.zip
          6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vgt Eirik Aavitsland
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes