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

Windows and macOS do not map font weight correctly for Montserrat variants

    XMLWordPrintable

Details

    • Windows

    Description

      In my QML application I use external font. The font contains several styles, each style in a separate file. All the files are in a resource.

       

      QList<QString> fonts = { "Montserrat-Black.otf", "Montserrat-BlackItalic.otf", "Montserrat-Bold.otf", "Montserrat-BoldItalic.otf", "Montserrat-Medium.otf", "Montserrat-MediumItalic.otf", "Montserrat-Regular.otf", "Montserrat-Italic.otf", "Montserrat-Light.otf", "Montserrat-LightItalic.otf", "Montserrat-Thin.otf", "Montserrat-ThinItalic.otf" };  
      
      foreach(const QString &font, fonts) { 
          if(QFontDatabase::addApplicationFont(":/fonts/" + font) == -1) 
              qDebug() << "Error loading font: " + font; 
      }

      Font usage:

      Button { 
          text: qsTr("Sign In") 
          font.weight: Font.Medium
          font.family: "Montserrat" 
      }
      Button { 
          text: qsTr("Sign In")
          font.pixelSize: 18
          font.weight: Font.Normal
          font.family: "Montserrat" 
       }
      

       

       

      The result:

      QML just ignores Font.Medium and display it as Font.Normal.

      That how it looks in Sketch:

      All the fonts are installed in Windows.

      If I try to change the font weight in Designer, only Normal and Bold make sense. All other weights are displayed as Normal.

       The Montserrat font could be found [here|http://example.com]

      Attachments

        1. image-2018-08-28-14-58-14-314.png
          image-2018-08-28-14-58-14-314.png
          3 kB
        2. image-2018-08-28-14-59-39-022.png
          image-2018-08-28-14-59-39-022.png
          1 kB
        3. image-2018-08-28-14-59-46-838.png
          image-2018-08-28-14-59-46-838.png
          1 kB
        4. fonttest.qml
          1 kB
        5. fonts.png
          fonts.png
          6 kB
        6. linux.png
          linux.png
          35 kB
        7. image-2018-09-26-09-31-44-610.png
          image-2018-09-26-09-31-44-610.png
          36 kB

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              folibis ruslan
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes