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

Qt font not found in certain windows versions



  • Hello!

    How exactly qrc qfonts are working?
    In a specific pc QFontDatabase::addApplicationFont returns -1, otherwise it's working.
    The font i am using is not in my windows and it's still working, so i guess qrc compile it into the executable, am i right here?
    If that's the case, what can cause addApplicationFont to randomly not work?

    In the Qrc it's added as

    <qresource prefix="[...]">
    <file alias="[...]">[...]</file>
    </qresource>

    Thank you!


  • Lifetime Qt Champion

    Hi
    Yes a qrc file is often compiled into the exe.
    Im not sure why it would fail.

    Is pc that fails the same Windows version ?



  • Hello!

    Thank you for the answer, it is a different a windows version (a Win10 enterprise), tho i don't see why would it matter if it's in the executable.


  • Lifetime Qt Champion

    @Melkon
    Hi
    It should not matter but just wondered if it might already have font or something like that to make addApplicationFont fail.

    Do you have access to the pc that fails for testing ?



  • So far it seems the app is working perfectly even without calling add application font, so maybe the solution will be to just remove it.

    I can get access to that pc, tho it's a bit problematic. Thanks for the tip, i'll check if these fonts are already there or not.


  • Lifetime Qt Champion

    @Melkon
    Hi
    Well, Windows will do font matching so if you ask for a given font, it will find one as close as possible if not a direct hit.
    So in many cases, it works just fine.

    Im not sure how to debug this but i would also check on the pc, that the (embedded) font file can be found

    #include <QFileInfo>
    
    bool fileExists(QString path) {
        QFileInfo check_file(path);
        return check_file.exists() && check_file.isFile();
    }
    

    Else im not sure what else could be the issue.



  • Okay, thank you very much!


Log in to reply