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

Fixed typeface gets blurred by antialiasing when centering offsets the font from the pixel grid; Qt ignores fontconfig antialiasing setting

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7, 6.8
    • Widgets: Styles
    • None
    • Rocky 9.2
    • Linux/X11

    Description

      This issue is reproducible in Qt Designer in Qt 6.7 and later, with the following stylesheet:

      QWidget

      {     font-family: fixed;     font-style:  normal;     font-size:   14px;     font-weight: bold; }

      Drag a QPushButton onto the frame, and make it bigger.

      Edit the text by adding and removing characters in the text field.

      Notice that if there are an odd number of characters in the text field and the widget's width is also odd, the font renders correctly.

      If there are an even number of characters in the text field and the widget's width is also even, the font renders correctly,

      but if the width is odd and the number of characters are even, the font is rendered as blurred by anti-aliasing.

      Note: the widget's height also has to be even.  If the widget's height is odd, the font renders blurry in the vertical direction.

      Before Qt 6.7, the fixed typeface font would render correctly, aligned with the pixel grid in all of the above scenarios.

      Since it is a pixel-based font, it shouldn't be anti-aliased.  You can't turn anti-aliasing on or off via the stylesheet, but it should respect the fontconfig settings.  For this font, Qt ignores any fontconfig settings for antialiasing and it blurs the font regardless of what fontconfig says.  You can directly set the Antialiasing property for the font, but if the style is appllied via a stylesheet at runtime, you can't configure that property according to a font selected in the stylesheet.

       

      By contrast, if "dejavusansmono" is used as the font with size "12px" (those settings have similar size properties to the fixed, size 14px font), whether anti-aliased or not, it manages to keep itself aligned with the pixel grid via hinting - and Qt respects the fontconfig settings for this font (dejavusansmono) unless explicitly overwritten.

       

      For some reason Qt 6.7 is defaulting to Antialiasing the fixed typeface, even though the font doesn't support antialiasing; it's ignoring fontconfig's setting for it to not antialias, and it's effectively blurring the font if centering doesn't align it with the pixel grid.

       

      The solution could be: Qt defaulting antialiasing to off for fonts like the fixed typeface.

      or Qt respecting the fact that fontconfig configures antialiasing to be off for the fixed typeface.

      Attachments

        1. calculator_issue.png
          7 kB
          Joshua Fletcher
        2. calculator-compare.png
          12 kB
          Joshua Fletcher
        3. designer-example.ui
          1 kB
          Joshua Fletcher
        4. example-in-designer.png
          50 kB
          Joshua Fletcher
        5. QTBUG-132904.png
          17 kB
          Joshua Fletcher
        6. QTBUG-132904.ui
          8 kB
          Joshua Fletcher
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            joshua.fletcher Joshua Fletcher
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes