Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Fontloader: Change font name for two different font styles



  • Hi,
    I try to use the FontAwesome icon fonts in a qml project. FontAwesome comes in the styles regular and solid. I downloaded the two corresponding .otf files from https://fontawesome.com/ and try to use them via fontloaders:

    FontLoader {id: fontawesome_solid; source: "qrc:/resource/fontawesome_solid.otf"}
    FontLoader {id: fontawesome_regular; source: "qrc:/resources/fontawesome_regular.otf"}
    

    The problem is, that the name of both of these two fonts is "Font Awesome 5 Free". Therefore, if I set font.style like this:

    Text {
              anchors {left: name.right; baseline: name.baseline}
              text: "\uF0DD"
              font.pixelSize: Style.fontSizeStandard
              textFormat: Text.RichText
              font.family: fontawesome_solid.name
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      console.log(fontawesome_solid.name)
                  }
              }
          }
    

    I cannot use symbols in the _solid.otf font. How can I avoid this naming problem?


Log in to reply