You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot use both regular and solid fonts together in the same Qt/QML application #12787
I often use Font Awesome in Qt/QML applications. In v4, this was quite straightforward, all that needed to be done was using a FontLoader and then set the font.family attribute of text elements to the font family (which could be retrieved via the FontLoader).
With v5, we now have several font files (e.g. there are 3 *.ttf files in the Free version). Generally, it is possible to use multiple FontLoaders to load all of them. However, I noticed that the font family for the regular and solid variants are the same. Hence, I cannot easily switch between the two by setting the font.family attribute of text objects.
I would have expected to be able to select the variant by one of the following:
Setting the font.weight property. This did not work out for some reasons - maybe a Qt issue?
Setting the font.styleName property, i.e. Solid vs Regular. However, this also did not work (because all the font files are set to Regular).
For the time being, I worked around the issue by editing the file fa-solid-900.ttf with FontForge and setting the font family to Font Awesome 5 Free Solid. With the modified *.ttf file I can easily switch between the two styles in my QML application. It would however be cool if Font Awesome would work out of the box with Qt/QML ;-)
Thanks for considering!
Btw: The brands font file seems to work just fine, however, this is probably due to it uses a different font family name compared to the other two.
Here, my expectation would have been that the lighter variants would use the icons from the regular font while the bolder ones use the one from the solid one.
@mhoeher I'm not sure I can be of much use to you. Those fonts are using different weight classes. I'm not sure how Qt handles that. You might try using the .OTF files instead if that's possible.
One of our application we are using is using the qt QFontDatabase (https://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont) class and we are having a similar problem with it not being able to distinguish between the light/regular/solid TTF webfonts. The developer of that software company informed us that the cause of the issue is because all these TTF fonts have the exact same name: "Font Awesome 5 Pro".
Can you please add "Light", "Regular", and "Solid" to the name of these fonts so that libraries like Qt can distinguish them?
after your hint I tried my example from above with the most recent release. The good news: Using the *.otf font files from the desktop release package, I now get the expected result:
So it seems there were some fixes for these files :-)
In addition, I tried with the .ttf fonts from the web fonts zip, but using these, I still get the wrong output shown in my earlier post.
Activity
tagliala commentedon Apr 6, 2018
Hi!
Thanks for being part of the Font Awesome Community.
Sorry but I cannot help. Let's wait for some feedback by the community
Please check with another font (with separate files for each style)
@robmadole is there something we can do about this?
mhoeher commentedon Apr 6, 2018
Hi @tagliala,
thanks for the hint! I tried to reproduce this with another Font (I tried with Comfortaa) by doing the following:
qmlscene font-weight-comfortaa.qml.The results:
On standard output it prints:
as expected. And the rendering is as follows:
Which looks as expected. Then, I tried the same with Font Awesome:
/web-fonts-with-css/webfonts/.qmlscene font-weight-fontawesome.qml.The result: On standard out it prints:
qml: Font Awesome 5 Free
qml: Font Awesome 5 Free
And the result is this:
Here, my expectation would have been that the lighter variants would use the icons from the regular font while the bolder ones use the one from the solid one.
robmadole commentedon Apr 10, 2018
@mhoeher I'm not sure I can be of much use to you. Those fonts are using different weight classes. I'm not sure how Qt handles that. You might try using the .OTF files instead if that's possible.
mhoeher commentedon Apr 10, 2018
Hi @robmadole,
I modified my sample from above and replaced the
*.ttffonts with the*.otfones, however, the result is the same. :-(huyder commentedon Jul 25, 2018
One of our application we are using is using the qt QFontDatabase (https://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont) class and we are having a similar problem with it not being able to distinguish between the light/regular/solid TTF webfonts. The developer of that software company informed us that the cause of the issue is because all these TTF fonts have the exact same name: "Font Awesome 5 Pro".
Can you please add "Light", "Regular", and "Solid" to the name of these fonts so that libraries like Qt can distinguish them?
tagliala commentedon Jul 25, 2018
Maybe this is the same issue as #13320
mhoeher commentedon Jul 29, 2018
Hi @tagliala,
after your hint I tried my example from above with the most recent release. The good news: Using the
*.otffont files from the desktop release package, I now get the expected result:So it seems there were some fixes for these files :-)
In addition, I tried with the
.ttffonts from the web fonts zip, but using these, I still get the wrong output shown in my earlier post.tagliala commentedon Jul 29, 2018
Glad you've solved.
.ttf files are not supposed to be used on the desktop, because they are generated for the web by a webfont script
mhoeher commentedon Jul 29, 2018
Okay, then I think this issue can be considered done ;-)
add fontawesome ttf to qrc. font loads in qmlscene, desktop, and android
add fontawesome ttf to qrc. font loads in qmlscene, desktop, and android
add fontawesome ttf to qrc. font loads in qmlscene, desktop, and android
add fontawesome ttf to qrc. font loads in qmlscene, desktop, and android