Qt Application Fonts Missing or Invisible in Linux (Fixed)

By default Qt does not copy fonts along with your application when you deploy them under Linux. I recently faced this issue and none of the texts or labels on my Qt windows showed anything on them. All labels and text were blank and the forms looked completely empty.

This happened on deploying a statically built application so I realized I needed to deploy my fonts along with my Qt app.

Here is how I fixed this issue:

First create a Qt Resource file and add your font into it.

Let’s assume that our font is Ubuntu’s default “Ubuntu-R.ttf” file, then we need to add the following into our main.cpp


qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false));

Voila! You should have your fonts back.

5 Replies to “Qt Application Fonts Missing or Invisible in Linux (Fixed)”

  1. Hey,
    thanks, this solved my Problem on my Computer, but when building an AppImage to run the Program the font is somehow lost, do you know another way to include the font?

    1. Not sure what you mean by “an AppImage”?!
      Can you be a little bit more specific? Are you trying this on Windows, Linux or macOS?
      Are you adding the font as a resource?
      Try to provide me with enough information about what you trying to do and what is the problem exactly?!

      1. An AppImage is just an packed Version of the created Program, that runs on multiple Linux distros without the need to create specific .deb or .rpm files. It is not importent that I used an AppImage, same issue without.

        And I’ve created an HelloWorld-program just to test fonts, so an button and a label to keep it simple. I added the font like your article page and it worked, but only on my computer (with fedora). When I tryed to run this program on an computer without Qt installed, the font did become invisible. I used an static build of Qt, so required Qt files should be included in the executable, but it seems that the font is not.

        1. I see, thanks for clarifying. However, it doesn’t seem right to try to run a Qt app on a computer without Qt libraries.
          You need to make sure Qt libraries exist on the target system. Have you checked the following link?!

          Please let me know if it is of any help or not.

          Another suggestion would be to create an installer that deploys the required Qt libraries, i.e. using Qt Installer Framework.

          1. Oh no, Qt-Applications work on computers without the Qt-libarys when they are build into the Application. To do this, you just have to compile the Qt-sources with -static

            And thanks for your suggestion, it helped me to find out that I have to compile the source code with -fontconfig. Problems solved.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.