Fonts in Qt/Embedded

Supported formats

Qt/Embedded supports four font formats:

Support for each of these font formats, except QPF which is always enabled, can be enabled or disabled independently by using the Qt/Embedded Features Definition There is support in Qt/Embedded for writing a QPF font file from any font, thus you can initially enable TTF and BDF formats, save QPF files for the fonts and sizes you need, then remove TTF and BDF support.

Memory requirements

With TTF fonts, each character in the font at a given point size is only rendered when first used in a drawing or metrics operation. With BDF fonts all characters are rendered when the font is used. With QPF fonts, the characters are stored in the same format as Qt uses when drawing.

As an example, a 10-point Times font containing the ASCII characters uses around 1300 bytes when stored in QPF format.

Taking advantage of the way the QPF format is structured, Qt/Embedded memory-maps the data rather than reading and parsing it. This reduces the RAM consumption even further.

The scalable fonts use a larger amount of memory per font, but these fonts can give a memory saving if many different sizes of each font are needed.

Smooth fonts

TTF, PFA, and QPF fonts can be rendered as smooth anti-aliased fonts to give superior readability, especially on low-resolution devices. The difference between smooth and non-smooth fonts is illustrated below (you may need to change your display to low resolution to see the difference).

In Qt/Embedded 2.2.1, smooth fonts use 8 times as much memory as non-smooth fonts. This multiplier will be reduced to a configurable 2 or 4 (ie. 4-level and 16-level shading rather than the current excessive 256-level shading).


All fonts used by Qt/Embedded use the Unicode character encoding. Most fonts available today do not actually contain all the Unicode characters, but they do use the Unicode characters ordering. A single complete 16-point Unicode font uses over 1Mb of memory.

The font definition file

When Qt/Embedded applications run, they look for a file called $QTDIR/lib/fonts/fontdir or /usr/local/qt-embedded/lib/fonts/fontdir. This file defines the fonts available to the application. It has the following format:

name file renderer italic weight size flags


name Helvetica, Times, etc.
file helvR0810.bdf, verdana.ttf, etc.
renderer BDF or FT
italic y or n
weight 50 is Normal, 75 is Bold, etc.
size 0 for scalable or 10 times pointsize (eg. 120 for 12pt)
flags Flag characters:
s = smooth (anti-aliased)
u = unicode range when saving (default is Latin 1)
a = ascii range when saving (default is Latin 1)

The font definition file does not specify QPF fonts - these are loaded directly from the directory containing the fontdir file, and must be named name_size_weightitalicflag.qpf, where:

name helvetica, times, etc. (lowercase)
size 10 times pointsize (eg. 120 for 12pt)
italicflag i for italic or nothing.
weight 50 is Normal, 75 is Bold, etc.

If an application is run with the -savefonts command-line option, then whenever a font other than a QPF font is used, a corresponding QPF file is saved. This allows you to easily find the font usage of your applications and to generate QPF files so that you can eventually reduce the memory usage of your applications by disabling TTF and BDF support from Qt/Embedded. option, or by modifying the initialization of qws_savefonts in kernel/qapplication_qws.cpp of the Qt/Embedded library source code. In extreme cases of memory-saving, it is possible to save partially-rendered fonts (eg. only the characters in "Product NameTM") if you are certain that these are the only characters you will need from the font. See QMemoryManager::savePrerenderedFont() for this functionality.


The font definition file, naming conventions for font files, and the format of QPF files may change in versions of Qt/Embedded.

To generate QPF files of different rotations, the program must be re-run with an orientation that matches the desired rotation of the QPF output. An example to generate all 4 rotations of fonts would be to run the following at a real framebuffer:

for dpy in LinuxFb Transformed:Rot90 Transformed:Rot180 Transformed:Rot270
    QWS_DISPLAY=$dpy ./makeqpf "$@"

If programs are only ever run in one orientation on a device, only the one appropriate set of fonts is needed.

When enabled, Qt/Embedded uses the powerful FreeType2 library to implement TrueType and Type1 support.

Helvetica BDF Fonts

The Helvetica BDF font files supplied with Qt/Embedded are distributed under the following highly permissive license. We recommend that all Qt/Embedded installations that use these font files also acknowledge this contribution, and quote this license statement in an appendix to the documentation. -- located in lib/fonts

Copyright 1984-1989, 1994 Adobe Systems Incorporated.

Copyright 1988, 1994 Digital Equipment Corporation.

Adobe is a trademark of Adobe Systems Incorporated which may be registered in certain jurisdictions. Permission to use these trademarks is hereby granted only in association with the images described in this file.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notices appear in all copies and that both those copyright notices and this permission notice appear in supporting documentation, and that the names of Adobe Systems and Digital Equipment Corporation not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Adobe Systems and Digital Equipment Corporation make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

Copyright © 2005 TrolltechTrademarks
Qt version 2.3.10