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

Accessing named styles of fonts after using the regular font doesn't always work (Mac only)

    XMLWordPrintable

Details

    • macOS
    • ffeefaac6273b8bdb81876a5cc26e15cb9353955
    • Bug Fixing Week Q2/2020

    Description

      The fix to QTBUG-19366 made it possible to access all styles of all fonts on the Mac, which is welcome. However, this sometimes fails, particularly if the regular font face has already been used.

      To reproduce this, build and run the attached test app on the Mac. This selects Helvetica Neue by default and draws a QTextDocument containing the style name that uses the current font. It also offers a list of the other styles that are available (using CoreText directly - there is no API for this in Qt). Try choosing any other style, eg. 'Semibold'. You'll see that the font (and the reported style name) doesn't change.

      The problem seems to be that the QFontCache thinks it's already loaded a font engine for the semibold font, and returns the regular font engine. This seems to be because the QFontDef comparison operators (and exactMatch) special-case the empty style name case so that if either of the style names are empty then the comparison will not take style name into account. This means that comparing any named style with the regular font that has no style name set will not work correctly.

      I'm not sure why this special case exists - it was introduced in 15e6ac8f but I don't really understand why.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            jlarcombe James Larcombe
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes