I am trying to show Font Aweseom 5 (5.10.2) icons in a Qt Qml label:
Label {
text: "\uf2bb" + " x " + "\uf002"
font.family: "Font Awesome 5 Free"
//font.weight: Font.Normal
}
On Windows all icons work as expected. But on all other platforms (macOS, Android, iOS) only some icons (for instance \
) are shown while others ( \
) do not work and a simple rectangle is shown instead. But all icons work on all platforms when QWidgets are used.
I verified that the "Font Awesome 5 Free" font is installed in the QFontDatabase using this utility list view:
ListView {
anchors.fill: parent;
model: Qt.fontFamilies()
delegate: Item {
height: 40;
width: ListView.view.width
Label {
anchors.centerIn: parent
text: modelData;
}
}
}
Has anyone an idea why some icons work in Qml, while others don't?
Regards,
Either setting the font weight to Font.Black
or the font's style name to "Solid"
fixes the problem:
Label {
text: "\uf2bb" + " x " + "\uf002"
font.family: "Font Awesome 5 Free"
font.weight: Font.Black // this does the trick
}
Label {
text: "\uf2bb" + " x " + "\uf002"
font.family: "Font Awesome 5 Free"
font.styleName: "Solid" // this does the trick
}
I fixed this problem with https://fontforge.org/
On file fa-solid-900.ttf I modified the field WWS Family
(under tab TTF Names) from Font Awesome 5 Free
to Font Awesome 5 Free Solid
Maybe Qt for Android uses this field and without modification the value is the same for fa-regular-400.ttf and fa-solid-900.ttf
Hope it helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.