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

Qt6: QFontDatabase does not addApplicationFont

Scheduled Pinned Locked Moved Unsolved Qt 6
16 Posts 6 Posters 2.1k Views
  • 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.
  • A achak
    8 Mar 2022, 09:28

    @jsulm I have big project used QT6. The fonts feature is last part of it. I can check the example on Qt 5 but this does not help me with my project :(

    C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 8 Mar 2022, 10:19 last edited by
    #6

    @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.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    A 1 Reply Last reply 8 Mar 2022, 12:57
    0
    • C Christian Ehrlicher
      8 Mar 2022, 10:19

      @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 8 Mar 2022, 12:57 last edited by
      #7

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

      J 1 Reply Last reply 8 Mar 2022, 12:59
      0
      • A achak
        8 Mar 2022, 12:57

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

        J Online
        J Online
        jsulm
        Lifetime Qt Champion
        wrote on 8 Mar 2022, 12:59 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 9 Mar 2022, 12:27
        0
        • J jsulm
          8 Mar 2022, 12:59

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

          A Offline
          A Offline
          achak
          wrote on 9 Mar 2022, 12:27 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?

          J 1 Reply Last reply 9 Mar 2022, 13:00
          0
          • A achak
            9 Mar 2022, 12:27

            @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?

            J Online
            J Online
            jsulm
            Lifetime Qt Champion
            wrote on 9 Mar 2022, 13:00 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
            • K Offline
              K Offline
              kkoehne
              Moderators
              wrote on 9 Mar 2022, 13:36 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 10 Mar 2022, 07:22
              1
              • K kkoehne
                9 Mar 2022, 13:36

                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 10 Mar 2022, 07:22 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
                • K Offline
                  K Offline
                  kkoehne
                  Moderators
                  wrote on 11 Mar 2022, 10:14 last edited by kkoehne 3 Nov 2022, 10:15
                  #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 14 Mar 2022, 13:53
                  0
                  • K kkoehne
                    11 Mar 2022, 10:14

                    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 14 Mar 2022, 13:53 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 17 Mar 2022, 16:08 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 23 Mar 2022, 19:34 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

                        15/16

                        17 Mar 2022, 16:08

                        • Login

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