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

Axes of some variable fonts don't work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.9.1
    • GUI: Font handling
    • None
    • Linux/X11

    Description

      For some fonts it seems, that the variableAxes qml property does not work, although google fonts does list them under variable axes, and google manages to make them variable. When using the code below, this shows by all Text lines being rendered with weight 400 (regular). It works correctly in Qt 6.7.3 and 6.8.2.

      Broken fonts are e.g. public sans and source sans 3. Working fonts are roboto, noto sans, and dyna puff. I've written the following qml app to demonstrate the issue (full project attached):

      import QtQuick
      import QtQuick.Controls.Material
      import QtQuick.Layouts
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
          id: root
      
          property string normalFamilyPath: "https://github.com/uswds/public-sans/raw/refs/heads/develop/fonts/variable/PublicSans%5Bwght%5D.ttf"
          FontLoader{ id: fontLoader; source: root.normalFamilyPath; }
      
      
          ListModel {
              id: fontModel
              ListElement { displayName: "PublicSans";
                  normalFamilyPath:    "https://github.com/google/fonts/raw/c53c4df931d3fd0122a30b06d13126cfaad8e014/ofl/publicsans/PublicSans%5Bwght%5D.ttf";
              }
              ListElement { displayName: "SourceSans3";
                  normalFamilyPath:    "https://github.com/google/fonts/raw/4591e3457ab8be6d70167aa6818922b91e78ab2d/ofl/sourcesans3/SourceSans3%5Bwght%5D.ttf";
              }
              ListElement { displayName: "Roboto";
                  normalFamilyPath:    "https://github.com/google/fonts/raw/980ecc3ef7368a861abfb636a42f0952cada6720/ofl/roboto/Roboto%5Bwdth,wght%5D.ttf";
              }
              ListElement { displayName: "Noto Sans";
                  normalFamilyPath:    "https://github.com/google/fonts/raw/b8a5c309307ae1f13ae03724fe46454ec63fad63/ofl/notosans/NotoSans%5Bwdth,wght%5D.ttf";
              }
              ListElement { displayName: "DynaPuff + PublicSans";
                  normalFamilyPath:    "https://github.com/google/fonts/raw/19cdcec59967f4aa6defb86bd0550dff1ac43abb/ofl/dynapuff/DynaPuff%5Bwdth,wght%5D.ttf";
              }
          }
      
          ColumnLayout {
              anchors.fill: parent
              ComboBox {
                  Layout.fillWidth: true
                  model: fontModel
                  textRole: "displayName"
      
                  onCurrentIndexChanged: {
                      const item = fontModel.get(currentIndex)
                      console.log("Selected:", item.displayName)
                      root.normalFamilyPath = item.normalFamilyPath
                  }
              }
              Text {
                  text: "Cats don't fly (weight 900)."
                  font {
                      family: fontLoader.name
                      variableAxes: { "wght": 900 }
                      pixelSize: 32
                  }
              }
              Text {
                  text: "Cats don't fly (weight 700)."
                  font {
                      family: fontLoader.name
                      variableAxes: { "wght": 700 }
                      pixelSize: 32
                  }
              }
              Text {
                  text: "Cats don't fly (weight 400)."
                  font {
                      family: fontLoader.name
                      variableAxes: { "wght": 400 }
                      pixelSize: 32
                  }
              }
              Text {
                  text: "Cats don't fly (weight 100)."
                  font {
                      family: fontLoader.name
                      variableAxes: { "wght": 100 }
                      pixelSize: 32
                  }
              }
          }
      }
      
      

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            adamce Adam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes