<< to CrossControl homepage

Support & Service Center

Adding custom fonts to Qt (display and Virtual Machine)

Printer-friendly versionPrinter-friendly versionPDF versionPDF version

Many fonts are included for use in Qt both in the Virtual Machine and on the displays, but many users will want to add their own custom fonts to their user interface or add fonts in other languages.

One thing to keep in mind is that not all fonts included in the Virtual Machine are included on the displays.  If you are using a font in the Virtual Machine and it looks different then on the display it is possible the font is not included on the display and needs to be loaded.  In which case you can follow the instructions below to load the correct font.


First, if the font is not included in the Virtual Machine it will need to be loaded into the virtual machine.  This will also mean it will not be included in the display.

To load into the virtual machine:

  • Download or acquire the font file.  These usually come in .ttf type format but may come in other formats.
  • Copy the font file into the '/usr/share/fonts/truetype' directory in the Virtual Machine.  This directory is read only by default, so you need to do the following:
    • Navigate to the directory where you have stored the font file
    • In the terminal window for this directory type 'sudo mv yourFontFileName /usr/share/fonts/truetype/'.  It should ask for the password to 'ccs'.  Type 'default'.
  • The virtual machine should automatically recognize and register the font.  It should now be available inside Qt as well since Qt gets its fonts through the Linux OS.


Once the font is loaded onto the Virtual Machine you should now see the font appear as an option for label type objects in your Qt application.  If you select the newly added font it should appear correctly in your Qt User Interface design window and if you build and run your application in the Virtual Machine the new font should appear correctly.  If you build and run your application on the display, however, you will not see your font appear and will instead see a default display font.  This is because the font is not loaded onto the display.


To load the font onto the display:

  • Copy the font file from your Virtual Machine to the display /opt directory
    • To do this navigate to the Virtual Machine directory '/usr/share/fonts/truetype/' where you put your font file
    • Copy to the display using the command 'sudo scp yourFontFileName root@yourIPAddress:/opt'
  • In your 'main.cpp' file in your Qt application add the following code:
#include <QFontDatabase>
int main(int argc, char *argv[])
	QFontDatabase fontDB;

The final product should look something like this: