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

Freetype Windows font backend reports wrong font weight

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.3.0 RC, 6.4.0
    • GUI: Font handling
    • None
    • -platform windows:fontengine=freetype
    • Windows

    Description

      With the Freetype font backend, the following should report font weight 900 but currently reports font weight 400:

      QFont font("Arial Black");
      font.setStyleName("Black");
      QFontInfo fontInfo(font);
      qDebug() << fontInfo.weight();
      

      To run this code with the Freetype backend, add command line parameter -platform windows:fontengine=freetype when running the executable.

      The issue was discovered in this code review comment: https://codereview.qt-project.org/c/qt/qtbase/+/399156/comment/6e62c91f_f07ac3c2/

      The code works fine with the GDI backend if you change setStyleName("Black") to setStyleName("Regular") and apply this patch. (The styleName change is necessary because Freetype registers the font as family/subfamily "Arial Black"/"Black" whereas GDI treats it as "Arial Black"/"Regular". This inconsistency was also discovered in the code review comment linked above but wasn't seen as critical.)

      Reproduction

      More extensive code example attached.

      Can also be tested with the tst_QFontDatabase::subFamilyMatching() test from https://codereview.qt-project.org/c/qt/qtbase/+/399156. The test should be adjusted after fixing this bug.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            nikwen Niklas Wenzel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes