QFontDatabase::addApplicationFont Linux not working



  • Hi, I'm trying to use a custom font in a Qt Quick application.

    1 - First of all I add the "Roboto-Regular.ttf" to my resource file.

    <RCC>
        <qresource prefix="/">
            <file>main.qml</file>
             .....
            <file>Fonts/Roboto-Regular.ttf</file>
        </qresource>
    </RCC>
    

    2 - I load the font and set up as default for the application. I can see the "Roboto" file display in the database while enumerating the font family

        QFontDatabase::addApplicationFont(":/Fonts/Roboto-Regular.ttf");
        QFontDatabase database;
        foreach (const QString &family, database.families()) {
            qDebug() << family;
        }
        QFont font("Roboto");
        app.setFont(font);
    

    3 - On the QML side, I have :

    Text { 
          Text : "\u2794"
    }
    

    4 - On Windows 7 and Linux Ubuntu this is well working, I'm seeing the symbol char
    5 - I try it on a Linux (custum image build with Yocto) but I got an empty text. No symbol displayed :( What could be the problem ? I try setting manually the font to the text item

    Text { 
          font.family : "Roboto"                // Not work
          font.family : "Roboto-Regular"        // Not work
          Text : "\u2794"
    }
    

    I'm really out of idea.


Log in to reply
 

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