Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. project fonts not being used
Forum Updated to NodeBB v4.3 + New Features

project fonts not being used

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 340 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I'm trying to use some custom fonts for my UI. Here are the fonts in project view:
    fonts.PNG
    and my code for enabling a couple of them:

        FontLoader {
            id: rubikSemiBold
            source: "qrc:/fonts/Rubik/static/Rubik-SemiBold.ttf"
            onStatusChanged: if (rubikSemiBold.status == FontLoader.Ready) console.log('Loaded')
        }
        FontLoader {
            id: rubikItalic
            source: "qrc:/fonts/Rubik/static/Rubik-Italic.ttf"
        }
    ...
        NavSymbol {
            id: homeIcon
            iconFile: "qrc:/icons/Home.png"
            labelText: "Home"
            fontFam: rubikItalic.name
        }
    ...
    // my Navsymbol.qml file
    RowLayout {
        id: navSymbol
        property string iconFile: "qrc:/icons/blank.png"
        property string labelText: "to be replaced"
        property string fontFam: "unknown"
        
          Image {
            source: navSymbol.iconFile
        }
        Label {
            text: navSymbol.labelText
            font {
                family: fontFam
                pixelSize: navSymbol.fontSize
            }
        }
    

    I'm not getting a runtime error, but the fonts aren't being used. Can someone see what I'm doing wrong?

    Thanks...

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      are the font files added to your qml.qrc file?

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      mzimmersM 1 Reply Last reply
      0
      • MarkkyboyM Markkyboy

        are the font files added to your qml.qrc file?

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @Markkyboy I don't have a qml.qrc file. The file the fonts are in is "resources.qrc:"

        <RCC>
            <qresource prefix="/">
                <file>fonts/Rubik/static/Rubik-Black.ttf</file>
                <file>fonts/Rubik/static/Rubik-BlackItalic.ttf</file>
                <file>fonts/Rubik/static/Rubik-Bold.ttf</file>
                <file>fonts/Rubik/static/Rubik-BoldItalic.ttf</file>
                <file>fonts/Rubik/static/Rubik-ExtraBold.ttf</file>
                <file>fonts/Rubik/static/Rubik-ExtraBoldItalic.ttf</file>
                <file>fonts/Rubik/static/Rubik-Italic.ttf</file>
                <file>fonts/Rubik/static/Rubik-Light.ttf</file>
                <file>fonts/Rubik/static/Rubik-LightItalic.ttf</file>
                <file>fonts/Rubik/static/Rubik-Medium.ttf</file>
                <file>fonts/Rubik/static/Rubik-MediumItalic.ttf</file>
                <file>fonts/Rubik/static/Rubik-Regular.ttf</file>
                <file>fonts/Rubik/static/Rubik-SemiBold.ttf</file>
                <file>fonts/Rubik/static/Rubik-SemiBoldItalic.ttf</file>
            </qresource>
        </RCC>
        

        which is in CMakeLists.txt:

           qt_add_executable(
           appnga_demo
           main.cpp
           icons.qrc
           resources.qrc
           ...
        

        The FontLoader seems to be finding the fonts (I tried substituting a nonsense name, and got an error, but I get no error with the "good" names). Somehow, they're just not being used.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved