Important: Please read the Qt Code of Conduct -

"Missing font family" warning on macOS

  • Hi, I'm working with Qt on macOS Cataline 10.15.6. I am working with Gnuplot 5.4 and I see that Qt 5.15.0 is installed although I am not sure if Gnuplot is making use of that or if it's statically linked.

    When I try any plot with Gnuplot, I get a warning about "missing font family", e.g.:

    gnuplot> plot sin(x)
    qt.qpa.fonts: Populating font family aliases took 175 ms. Replace uses of missing font family "Sans" with one that exists to avoid this cost. 

    How can I configure Qt, or set an environment variable, or use a runtime option, or otherwise inform Qt as to the presence or absence of some fonts? What should I tell it?

    I am not sure whether the responsibility for handling this font configuration question rests on Qt or on Gnuplot; in any event, if I can find out what Gnuplot needs to tell Qt, I can go to the Gnuplot developers and ask them about it.

    EDIT: I see now that Gnuplot is confiuring its default Qt terminal with font "Sans,9". So that's where "Sans" mentioned in the warning message is coming from. If I change the font to "Arial,9", the warning goes away. That makes me wonder how I can determine the list of acceptable font names; any info about that would be terrific.

    SECOND EDIT: It appears that, within a Qt application, QFontDatabase supplies the list of available fonts. How does QFontDatabase determine that list? Perhaps QFontDatabase is reading a system-wide list or configuration of some kind -- what might that be? How can I know, from outside of a Qt application, what is the list of fonts which QFontDatabase knows about?

    Thank you for any advice! I appreciate your help.

    Robert Dodier

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QFondDatabase requests the information from the system. If you want the gory details, you should take a look at its implementation.

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

  • Lifetime Qt Champion

    I understood you wanted to know what API was used.

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

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

  • Lifetime Qt Champion

    @f-kurushin with GnuPlot ?

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

  • 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".

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

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

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

Log in to reply