Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt6: QFontDatabase does not addApplicationFont
Qt 6.11 is out! See what's new in the release blog

Qt6: QFontDatabase does not addApplicationFont

Scheduled Pinned Locked Moved Unsolved Qt 6
16 Posts 6 Posters 5.3k 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.
  • Christian EhrlicherC Christian Ehrlicher

    @achak said in Qt6: QFontDatabase does not addApplicationFont:

    can check the example on Qt 5 but this does not help me with my project

    But it would solve the question if it's a regression or not.

    A Offline
    A Offline
    achak
    wrote on last edited by
    #7

    @Christian-Ehrlicher What is simplest way for check old version.

    jsulmJ 1 Reply Last reply
    0
    • A achak

      @Christian-Ehrlicher What is simplest way for check old version.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @achak Install Qt 5.15.2 and build your app using it.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @achak Install Qt 5.15.2 and build your app using it.

        A Offline
        A Offline
        achak
        wrote on last edited by
        #9

        @jsulm said in Qt6: QFontDatabase does not addApplicationFont:

        @achak Install Qt 5.15.2 and build your app using it.

        Unfortunatelly, by our policy I cannot install another version QT.
        The QT 5.15 is unsupported from 69/5/2021. If the sample works on 5.15, how it will support the issue?

        jsulmJ 1 Reply Last reply
        0
        • A achak

          @jsulm said in Qt6: QFontDatabase does not addApplicationFont:

          @achak Install Qt 5.15.2 and build your app using it.

          Unfortunatelly, by our policy I cannot install another version QT.
          The QT 5.15 is unsupported from 69/5/2021. If the sample works on 5.15, how it will support the issue?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #10

          @achak As @Christian-Ehrlicher wrote: checking whether or not it works with Qt5 is just to see whether there is a regression in Qt6. Means: if it works in Qt5 but not in Qt6 then something was broken in Qt6.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • kkoehneK Offline
            kkoehneK Offline
            kkoehne
            Moderators
            wrote on last edited by
            #11

            In addition, you might want to enable the qt.qpa.fonts category and see whether it prints any helpful debug messages on why your fons are not loaded: https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

            Director R&D, The Qt Company

            A 1 Reply Last reply
            1
            • kkoehneK kkoehne

              In addition, you might want to enable the qt.qpa.fonts category and see whether it prints any helpful debug messages on why your fons are not loaded: https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

              A Offline
              A Offline
              achak
              wrote on last edited by
              #12

              @kkoehne said in Qt6: QFontDatabase does not addApplicationFont:

              qt.qpa.fonts

              Thanks!!
              Following is output:

              qt.qpa.fonts: systemDefaultFont QFont(Segoe UI,9,-1,5,400,0,0,0,0,0,0,0,0,0,0,1)
              qt.qpa.fonts: QWindowsFontDatabase Clear type:  true gamma:  1.2
              qt.qpa.fonts: systemDefaultFont QFont(Segoe UI,9,-1,5,400,0,0,0,0,0,0,0,0,0,0,1)
              qt.qpa.fonts: "Segoe UI"
              qt.qpa.fonts: "addFontToDatabase Segoe UI 0 TTF=1 TRUETYPE scalable=1 Size=65535 Style=0 Weight=400 stretch=100"
              qt.qpa.fonts: "addFontToDatabase Segoe UI 0 TTF=1 TRUETYPE scalable=1 Size=65535 Style=0 Weight=700 stretch=100"
              qt.qpa.fonts: "addFontToDatabase Segoe UI 0 TTF=1 TRUETYPE scalable=1 Size=65535 Style=1 Weight=700 stretch=100"
              qt.qpa.fonts: "addFontToDatabase Segoe UI 0 TTF=1 TRUETYPE scalable=1 Size=65535 Style=1 Weight=400 stretch=100"
              qt.qpa.fonts: createEngine "Segoe UI" 9 pt hintingPreference= QFont::PreferDefaultHinting color= false 96 dpi useDirectWrite= false
              qt.qpa.fonts: QWindowsFontEngine "Segoe UI" -12
              qt.qpa.fonts: fontEngine FONTDEF QFontDef(Family="Segoe UI", pointsize=9, pixelsize=12, styleHint=5, weight=400, stretch=100, hintingPreference=0) 0x2ce0360 0x0
              
              1 Reply Last reply
              0
              • kkoehneK Offline
                kkoehneK Offline
                kkoehne
                Moderators
                wrote on last edited by kkoehne
                #13

                Hi, unfortunately the output isn't as informative as I have hoped :(

                I just gave https://github.com/eyllanesc/stackoverflow/tree/master/questions/55585443 a test drive; the example works for me with Qt 6.2.2, both with MSVC and MinGW.

                Can you try also with Qt 6.2.2?

                Director R&D, The Qt Company

                A 1 Reply Last reply
                0
                • kkoehneK kkoehne

                  Hi, unfortunately the output isn't as informative as I have hoped :(

                  I just gave https://github.com/eyllanesc/stackoverflow/tree/master/questions/55585443 a test drive; the example works for me with Qt 6.2.2, both with MSVC and MinGW.

                  Can you try also with Qt 6.2.2?

                  A Offline
                  A Offline
                  achak
                  wrote on last edited by
                  #14

                  @kkoehne I trie on QT 6.2.2. I installed 6.2.3 on clear machine ( no QT 5 before) - the font did not set.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    achak
                    wrote on last edited by
                    #15

                    Last days I tried the example on vers 6.2. 6.2.2 and 6.2.3 on differnt machines. The ties was on both Debug and Releas. Alltime is same issue :(

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      liteyear
                      wrote on last edited by
                      #16

                      I got this working in 6.2.3 recently. At first I was tripped up by the qrc path. Note that if you have something like:

                      qml.files = $$files(*.qml)
                      qml.prefix = /qml
                      fonts.files = $$files(fonts/*)
                      fonts.prefix = / # will automatically get directory name "fonts" as prefix
                      RESOURCES += qml fonts
                      

                      in your .pro file, then Qt will expect to find qml files in the top-level directory, but their qrc path will have a "/qml" prefix. On the other hand it will expect to find ttf files in the fonts subdirectory, and still need to be accessed using a "/fonts" prefix.

                      So with the /pro above, this works for me in main.cpp:

                      QFontDatabase::addApplicationFont(":/fonts/Arial.ttf");
                      QFontDatabase::addApplicationFont(":/fonts/Arial Italic.ttf");
                      QFontDatabase::addApplicationFont(":/fonts/Arial Bold.ttf");
                      QFontDatabase::addApplicationFont(":/fonts/Arial Bold Italic.ttf");
                      

                      returning 0, 1, 2 and 3 respectively.

                      Also remember to clean your build before re-building, because the qrc resource files might be pre-built by qmake.

                      PS. I'm not recommending anyone distribute Arial with your app. Do you own legal research.

                      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