Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "Missing font family" warning on macOS

"Missing font family" warning on macOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 11 Posters 13.0k 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.
  • R Offline
    R Offline
    Robert Dodier
    wrote on 24 Sept 2020, 19:21 last edited by
    #3

    Well, I don't mean to be ungrateful, but this is a somewhat unsatisfying answer ... Surely there is a way to know the list of available fonts without delving into the source code. It seems like something more common than a "gory detail".

    I will read the source code if it turns out that's necessary, but it seems plausible that there is another way.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Sept 2020, 19:25 last edited by
      #4

      I understood you wanted to know what API was used.

      macOS has Font Book. You can find the list of fonts in Catalina here.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply 22 Dec 2020, 22:42
      1
      • S SGaist
        24 Sept 2020, 19:25

        I understood you wanted to know what API was used.

        macOS has Font Book. You can find the list of fonts in Catalina here.

        F Offline
        F Offline
        f.kurushin
        wrote on 22 Dec 2020, 22:42 last edited by
        #5

        @SGaist I have the same problem, I ve installed "Garamond " font, but the problem is still here...

        S 1 Reply Last reply 23 Dec 2020, 20:23
        0
        • F f.kurushin
          22 Dec 2020, 22:42

          @SGaist I have the same problem, I ve installed "Garamond " font, but the problem is still here...

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 23 Dec 2020, 20:23 last edited by
          #6

          @f-kurushin with GnuPlot ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MissingFont
            wrote on 14 Feb 2021, 23:10 last edited by MissingFont
            #7

            same issue here!
            this issue:

            qt.qpa.fonts: Populating font family aliases took 252 ms. Replace uses of missing font family "Sans" with one that exists to avoid this cost.
            

            has been posted almost everywhere, e.g. at github, stakeoverflow, at octave and here at QT.

            It said to have been solved at 5.15.2, but for me, 5.15.2 at macOS 10.15.6 not either.

            please review. and find the root cause and help suggest a solution. thanks!

            EDIT: one the solution I found is, set env e.g. at macOS: ~/.gnuplot ( for Windows is gnuplot.ini):

            set term qt font "Arial 12"
            

            then no complain.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Strangelove
              wrote on 13 Aug 2021, 17:13 last edited by Strangelove
              #8

              I am regularly getting this error too, with PySide 6.1.2, and I'm not using Gnuplot. The only font my application refers to explicitly is "Helvetica Neue" which is present by default on any macOS Catalina system, including mine.

              The error I get doesn't mention "Sans" but rather some mysterious "H", as in:

              qt.qpa.fonts: Populating font family aliases took 253 ms. Replace uses of missing font family "H" with one that exists to avoid this cost. 
              

              EDIT: the mysterious "H" is definitely related to "Helvetica Neue" because when I changed the font in the app to Garamond, I got the same message with a (less mysterious) "G".

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JoeCFD
                wrote on 13 Aug 2021, 17:39 last edited by
                #9

                If the font used in qt app is not found on Linux, it can take long for the app to go through all fonts( a lot of unused in default installation) and the widgets which use the font can be frozen during the looking-up time.

                S 1 Reply Last reply 13 Aug 2021, 17:42
                0
                • J JoeCFD
                  13 Aug 2021, 17:39

                  If the font used in qt app is not found on Linux, it can take long for the app to go through all fonts( a lot of unused in default installation) and the widgets which use the font can be frozen during the looking-up time.

                  S Offline
                  S Offline
                  Strangelove
                  wrote on 13 Aug 2021, 17:42 last edited by Strangelove
                  #10

                  @JoeCFD Is there a way I can go through this search when the app starts? I tried calling QFont with the font name and assigning it to a dummy variable but it didn't change anything.

                  EDIT: Solved by actually assigning the font to something, as early as possible (such as in the QApplication constructor):

                  self.setFont(QFont('Helvetica Neue'))
                  

                  The message still appears but (1) it doesn't add a delay the first time a widget uses the font and (2) it pollutes the console as early as possible.

                  J 1 Reply Last reply 13 Aug 2021, 21:54
                  0
                  • S Strangelove
                    13 Aug 2021, 17:42

                    @JoeCFD Is there a way I can go through this search when the app starts? I tried calling QFont with the font name and assigning it to a dummy variable but it didn't change anything.

                    EDIT: Solved by actually assigning the font to something, as early as possible (such as in the QApplication constructor):

                    self.setFont(QFont('Helvetica Neue'))
                    

                    The message still appears but (1) it doesn't add a delay the first time a widget uses the font and (2) it pollutes the console as early as possible.

                    J Offline
                    J Offline
                    JoeCFD
                    wrote on 13 Aug 2021, 21:54 last edited by JoeCFD
                    #11

                    @Strangelove A better way to do it is to release your app with the font used. That will make sure it is available all the time.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ademmler
                      wrote on 26 Feb 2022, 21:00 last edited by
                      #12

                      Seems like this bug is back. From my Mac OS X Mojave computer using Qt 15.5.8

                      "qt.qpa.fonts: Populating font family aliases took 1268 ms. Replace uses of missing font family "Verdana" with one that exists to avoid this cost. "

                      How to overcome this?

                      @JoeCFD I am using Qt default fonts ... How to test/check what's going on ....

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        CrazyChucky
                        wrote on 27 Feb 2022, 23:23 last edited by CrazyChucky
                        #13

                        I'm getting the same error, running PySide/Qt 6.2.3 on macOS Mojave 10.14.6:

                        qt.qpa.fonts: Populating font family aliases took 2081 ms. Replace uses of missing font family ".SF NS Text" with one that exists to avoid this cost.

                        I've specified no styling or fonts, so this is just the default; thus San Francisco, the default system font on Mojave, is a perfectly plausible choice. The only question is why Qt isn't finding it.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          syr123
                          wrote on 25 Jun 2022, 00:56 last edited by
                          #14

                          I'm also getting it, really frustrating. On Monterey 12.2, Python version: 3.9.5, PySide6 version: 6.3.0

                          I'm explicitly adding a font local to my app to the QFontDatabase early in the apps run:

                              fontpath = os.path.abspath("resources/fonts/Futura-Light.otf")
                              _id = QFontDatabase.addApplicationFont(fontpath)
                          

                          Then, each time I need it I use:

                              font = QFontDatabase.font('Futura', "Light", con.searchBarFontSize)
                          

                          I get:

                          qt.qpa.fonts: Populating font family aliases took 188 ms. Replace uses of missing font family "Futura" with one that exists to avoid this cost.

                          C 1 Reply Last reply 25 Jun 2022, 02:11
                          0
                          • hskoglundH Offline
                            hskoglundH Offline
                            hskoglund
                            wrote on 25 Jun 2022, 01:36 last edited by
                            #15

                            Hi, just tested with C++, I'm on Monterey 12.4 Xcode 13.4.1 and Qt 6.3.1. Downloaded Futura-Light.otf, created an empty widget app with a listwidget and tried this code at start (in mainwindow's constructor):

                            QFontDatabase::addApplicationFont("/Users/henry/Downloads/futura-light-opentype.otf");
                            auto font = QFontDatabase::font("Futura","Light",24);
                            ui->listWidget->setFont(font);
                            

                            and I get no error message (and the Futura Light font is visible in that listwidget).

                            Note that it's difficult to get that error "qt.qpa.fonts: Populating font family aliases to...." from a call to QFontDatabase::font (at least in C++) if I try

                            QFontDatabase::addApplicationFont("/Users/henry/Downloads/futura-light-opentype.otf");
                            auto font = QFontDatabase::font("Futurama","Light",24);
                            ui->listWidget->setFont(font);
                            

                            no Futura font shows up in my listwidget but also no error message
                            however if I try:

                            QFontDatabase::addApplicationFont("/Users/henry/Downloads/futura-light-opentype.otf");
                            auto font = QFont("Futurama",24);
                            ui->listWidget->setFont(font);
                            

                            no Futura font shows up and now I get "Populating font family aliases took 215 ms. Replace uses of missing font family "Futurama" with one that exists to avoid this cost."

                            So perhaps your error message is due to some call to QFont(....) and not QFontDatabase.font?

                            1 Reply Last reply
                            0
                            • S syr123
                              25 Jun 2022, 00:56

                              I'm also getting it, really frustrating. On Monterey 12.2, Python version: 3.9.5, PySide6 version: 6.3.0

                              I'm explicitly adding a font local to my app to the QFontDatabase early in the apps run:

                                  fontpath = os.path.abspath("resources/fonts/Futura-Light.otf")
                                  _id = QFontDatabase.addApplicationFont(fontpath)
                              

                              Then, each time I need it I use:

                                  font = QFontDatabase.font('Futura', "Light", con.searchBarFontSize)
                              

                              I get:

                              qt.qpa.fonts: Populating font family aliases took 188 ms. Replace uses of missing font family "Futura" with one that exists to avoid this cost.

                              C Offline
                              C Offline
                              ChrisW67
                              wrote on 25 Jun 2022, 02:11 last edited by
                              #16

                              @syr123 said in "Missing font family" warning on macOS:

                              I'm also getting it, really frustrating. On Monterey 12.2, Python version: 3.9.5, PySide6 version: 6.3.0
                              I'm explicitly adding a font local to my app to the QFontDatabase early in the apps run:
                              fontpath = os.path.abspath("resources/fonts/Futura-Light.otf")

                              Using a relative path to the font file is very fragile. Calling abspath() will not help. It will be considered relative to the running executable current working directory. This directory is unlikely to be in the source tree and variable even if it sometimes is in the source tree, with the result that the font is not found, not added, and the fallback behaviour still exists.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                syr123
                                wrote on 25 Jun 2022, 02:25 last edited by syr123
                                #17

                                Thank you both for taking a look. @hskoglund, I searched my whole project and have eliminated all calls to QFont(...). They're all:

                                font = QFontDatabase.font('Futura', "Light", 18)
                                

                                @ChrisW67 - I moved my font initialization as early in the app as I can, immediately after the QApplication(sys.argv) call. I replaced the font path with an absolute path as well, so I'm fairly certain it's not an issue with path resolution.

                                Is there any way I can get Qt to print what line is triggering the "qt.qpa.fonts" warning?

                                1 Reply Last reply
                                0
                                • C Offline
                                  C Offline
                                  ChrisW67
                                  wrote on 25 Jun 2022, 04:32 last edited by ChrisW67
                                  #18

                                  You are asking for a font family "Futura" and the system is telling you it does not exist. The system scans the entire font database trying to find the non-existent family name, or something aliased to it. That takes some time and generates the warning.

                                  Assuming it is loading correctly, the OpenType font you have manually loaded probably provides a font family name "Futura Light" (as this one does) and not "Futura". What happens if you use that family name?

                                  On my Linux system an attempt to match "Futura" will return font "Futura Light" if there is no exact match. On MacOS the behaviour seems different.

                                  $ fc-scan futura-light.otf 
                                  Pattern has 24 elts (size 32)
                                          family: "Futura Light"(s) "Futura"(s)
                                          familylang: "en"(s)
                                          style: "Regular"(s) "Light"(s)
                                          stylelang: "en"(s)
                                          fullname: "Futura-Light"(s) "Futura Light"(s)
                                          fullnamelang: "en"(s)
                                          slant: 0(i)(s)
                                          weight: 50(f)(s)
                                          width: 100(f)(s)
                                          foundry: "adobe"(s)
                                          file: "futura-light.otf"(s)
                                          index: 0(i)(s)
                                          outline: True(s)
                                          scalable: True(s)
                                          charset: 
                                          0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffdffe ffffffff ffffffff
                                          0001: 00000000 00020000 000c0006 61000003 00040000 00000000 00000000 00000000
                                          0002: 00000000 00000000 00000000 00000000 00000000 00000000 3f0000c0 00000000
                                          0020: 77180000 06010047 00000010 00000000 00000000 00000000 00000000 00000000
                                          0021: 00000000 00000004 00000000 00000000 00000000 00000000 00000000 00000000
                                          0022: 00040000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                                          00fb: 00000006 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                                  (s)
                                          lang: aa|ay|bi|br|ch|co|da|de|en|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|ia|id|ie|io|is|it|lb|mg|nb|nds|nl|nn|no|nr|nso|oc|om|pt|rm|sma|smj|so|sq|ss|st|sv|sw|tl|tn|ts|uz|vo|vot|wa|xh|yap|zu|an|fil|ht|jv|kj|kwm|li|ms|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za(s)
                                          fontversion: 65536(i)(s)
                                          capability: "otlayout:latn"(s)
                                          fontformat: "CFF"(s)
                                          decorative: False(s)
                                          postscriptname: "Futura-Light"(s)
                                          color: False(s)
                                          symbol: False(s)
                                          variable: False(s)
                                  
                                  $ fc-match Futura
                                  futura-light.otf: "Futura Light" "Regular"
                                  

                                  Or from Qt 5 or 6:

                                  #include <QApplication>
                                  #include <QFontDatabase>
                                  #include <QFont>
                                  #include <QDebug>
                                  
                                  int main(int argc, char **argv) {
                                          QApplication app(argc, argv);
                                  
                                          int fontId = QFontDatabase::addApplicationFont("./futura-light.otf");
                                          qDebug() << fontId;
                                  
                                  #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
                                          QFontDatabase fd;
                                          QFont font = fd.font("Futura", "Light", 12);
                                  #else
                                          QFont font = QFontDatabase::font("Futura", "Light", 12);
                                  #endif
                                          qDebug() << font;
                                  
                                          return 0;
                                  }
                                  
                                  0
                                  QFont( "Futura,12,-1,5,25,0,0,0,0,0,Light" )
                                  
                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    syr123
                                    wrote on 25 Jun 2022, 18:04 last edited by
                                    #19

                                    You say "You are asking for a font family "Futura" and the system is telling you it does not exist."

                                    Part of the reason I am suspicious of this claim is that I've used the Glyphs app to modify the otf file, to add weight to each glyph of the font and change the appearance a bit. And, when I run my app, the labels using Futura Light do display with this modified font.

                                    Additionally, QFontDatabase::addApplicationFont claims "The function returns -1 if the font could not be loaded." - when I inspect the return value of this function after adding my font with an absolute path, I see an ID of 0. So, it seems it is being correctly added to the QFontDatabase.

                                    On your recommendation I tried replacing all my calls of:

                                    font = QFontDatabase.font('Futura', "Light", 18)
                                    

                                    with

                                    font = QFontDatabase.font("Futura Light", "Futura", 18)
                                    

                                    After doing so, I no longer got the qt.qpa..fonts error, but all my fonts were displayed a a small bold Helvetica like font.

                                    This is what I get running fc-scan directly on my modified otf:

                                    src/resources/fonts --> fc-scan Futura-Light.otf 
                                    Pattern has 26 elts (size 32)
                                    	family: "Futura"(s) "Futura Light"(s)
                                    	familylang: "en"(s) "en"(s)
                                    	style: "Light"(s) "Regular"(s)
                                    	stylelang: "en"(s) "en"(s)
                                    	fullname: "Futura Light"(s)
                                    	fullnamelang: "en"(s)
                                    	slant: 0(i)(s)
                                    	weight: 50(f)(s)
                                    	width: 100(f)(s)
                                    	foundry: "ADBE"(s)
                                    	file: "Futura-Light.otf"(s)
                                    	index: 0(i)(s)
                                    	outline: True(s)
                                    	scalable: True(s)
                                    	charset: 
                                    	0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
                                    	0001: 00000000 00020000 000c0006 61000003 00040000 00000000 00000000 00000000
                                    	0002: 00000000 00000000 00000000 00000000 00000000 00000000 3f0002c0 00000000
                                    	0003: 00000000 00000000 00000000 00000000 00000000 10000000 00000000 00000000
                                    	0020: 77180000 06010047 00000010 00000000 00000000 00001000 00000000 00000000
                                    	0021: 00000000 00000004 00000000 00000000 00000000 00000000 00000000 00000000
                                    	0022: 02240000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                                    	00fb: 00000006 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                                    (s)
                                    	lang: aa|ay|bi|br|ch|co|da|de|en|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|ia|id|ie|io|is|it|lb|mg|nb|nds|nl|nn|no|nr|nso|oc|om|pt|rm|sma|smj|so|sq|ss|st|sv|sw|tl|tn|ts|uz|vo|vot|wa|xh|yap|zu|an|fil|ht|jv|kj|kwm|li|ms|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za(s)
                                    	fontversion: 65536(i)(s)
                                    	capability: "otlayout:DFLT otlayout:latn"(s)
                                    	fontformat: "CFF"(s)
                                    	decorative: False(s)
                                    	postscriptname: "Futura-Light"(s)
                                    	color: False(s)
                                    	symbol: False(s)
                                    	variable: False(s)
                                    	fonthashint: False(s)
                                    	order: 0(i)(s)
                                    

                                    Calls to get the font like this:

                                    font = QFontDatabase.font("Futura", "Light", 120)
                                    

                                    consistently display my labels as expected.

                                    Further confusing me, the following very simple test successfully loads my custom font and gives no error:

                                    def main():
                                    
                                      app = QApplication(sys.argv)
                                    
                                      fontpath = "/Users/Shared/se3/src/se3/src/resources/fonts/Futura-Light.otf"
                                      _id = QFontDatabase.addApplicationFont(fontpath)
                                      font = QFontDatabase.font("Futura", "Light", 120)
                                    
                                      from PySide6.QtGui import QFont
                                    
                                      label = QLabel(alignment=Qt.AlignCenter)
                                      label.setFont(font)
                                      label.setText("test")
                                      label.resize(640, 480)
                                      label.show()
                                    
                                      sys.exit(app.exec())
                                    
                                    
                                    if __name__ == "__main__":
                                      main()
                                    

                                    I do not get the qt.qpa error.

                                    This is why I was asking to know if there is any way to determine (in Python) which QFontDatabase.font database call in my much larger app was triggering the warning. I've searched the full source and don't see any calls to QFont or QFontDatabase that aren't in the form

                                      font = QFontDatabase.font("Futura", "Light", 120)
                                    

                                    Happy to try anything else you can think of, thanks for your help.

                                    1 Reply Last reply
                                    0
                                    • aha_1980A aha_1980 referenced this topic on 19 Feb 2025, 17:39

                                    • Login

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