[SOLVED] Qt5: Cannot set application font (OTF) from resource



  • Hi,
    i have a problem setting an customized application font, loaded from resource file.

    I added an OTF font to my resource file.

    Then i try to set this font as default application font like this:

    @if(-1 == QFontDatabase::addApplicationFont("qrc:/resources/Mohave.otf"))
    {
    qCritical() << "couldn't add application font";
    }@

    But somehow it does not work.

    The output is:

    @Unable to register font: Error Domain=com.apple.coretext Code=-1 "The operation couldn’t be completed. (com.apple.coretext error -1 - Could not register the font file 'qrc:/resources/Mohave.otf -- file://localhost/development/qtcreator-workspace/test/trunk/TEST-App/')" UserInfo=0x101f24cb0 {NSDescription=Could not register the font file 'qrc:/resources/Mohave.otf -- file://localhost/development/qtcreator-workspace/test/trunk/TEST/', CTFailedFontFileURL=qrc:/resources/Mohave.otf -- file://localhost/development/qtcreator-workspace/test/trunk/TEST/}
    couldn't add application font@

    I am using Mac OS but this font should be used for all devices (Android, iOS...)

    Any ideas?

    Greetings,
    Nando



  • News:

    Somehow without using the Qt resource file like this it works:

    @if(-1 == QFontDatabase::addApplicationFont("resources/Mohave.otf"))
    {
    qCritical() << "couldn't add application font";
    }@



  • can you post the content of the qrc fiile? I thing is a path isue here. did yu tried @:/resources/Mohave.otf@



  • That's it ;)
    Thank you!!!

    [quote author="arsinte_andrei" date="1410546027"]can you post the content of the qrc fiile? I thing is a path isue here. did yu tried @:/resources/Mohave.otf@[/quote]



  • I have the same problem:

    @
    if(QFontDatabase::addApplicationFont(":/tex-gyre-adventor.bold.otf") == -1)
    qCritical << "no font loaded";
    @

    output:
    @
    program received signal -111, thread:40e9;qaddr:3c4a1280;00:00000000;01:406nd07;02:f85 ecc ecc
    @



  • I have the same problem:

    @
    if(QFontDatabase::addApplicationFont(":/tex-gyre-adventor.bold.otf") == -1)
    qCritical << "no font loaded";
    @

    output:
    @
    program received signal -111, thread:40e9;qaddr:3c4a1280;00:00000000;01:406nd07;02:f85 ecc ecc
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.