emWin Fonts
emWin provides various font formats to meet different requirements. These fonts can be stored in external memory or compiled and linked with the application. In addition to emWin's proprietary font formats, it is also possible to display True Type Fonts (TTF).
Font formats
emWin supports the following font formats.
C file format
This is most likely the most common and easiest way to use a font with emWin. The font data is located in a single c file which can be compiled along with application and are most likely the fastest font format.
C file fonts support 1 bpp font data as well as 2 and 4 bpp anti-aliasing. The downside is the relatively high flash memory consumption due to the nature of this type of font.
This type of font format can be created with the Font Converter tool of emWin. C file fonts can be created from any TTF file located on the host machine.
System independent font format (SIF)
System independent fonts are binary versions of the C file fonts. They offer the same functionality but can be placed in external memory. This format is useful if the font is unknown at compile time, as it can be interchanged later on. The disadvantage of this font type is the relatively high memory requirement, as the entire file needs to be loaded into memory before it can be used.
Just like c file fonts the SIF format can be created with the Font Converter tool.
External bitmap font format (XBF)
Similar to the SIF format, the XBF format contains binary font data and can be created with the Font Converter. Unlike other fonts, XBF fonts do not need to reside in memory when used; all other types of emWin fonts must be fully loaded into memory. The XBF font file can remain on any external media while in use, with data accessed via a GetData callback function. The advantage of XBF fonts is that they allow the use of very large fonts on systems with limited memory.
A format description of the XBF format can be found in the emWin user manual.
TrueType font format (TTF)
Support for TrueType fonts can be added to emWin free of charge with downloadable extension. This extension package is uses the FreeType font library (freetype.org).
The extension package can be downloaded here.
This font format should be used if fonts need to be scalable at run time. On the downside this format requires quite some memory as TTF files can be very large.
More information can be found in the emWin user manual.
Glyph bitmap distribution format (BDF)
emWin is also capable of displaying BDF fonts. This is also achieved by utilizing the FreeType library.
This format is quite old and should only be used if there are no other options for font files.
Creating emWin font files
To create font files other than TTF and BDF the Font Converter tool is required. More information about the font converter can be found on our website and in the emWin user manual.
Keeping the footprint low
Fonts can easily eat up your available memory. Fortunately, there are a couple of things you can do to keep the footprint low.
Remove characters
If you already know the exact characters used in your application you can shrink the font files to only these characters. We'd recommend to use a pattern file which holds all string to be displayed. The Font Converter can use this pattern file to remove any other character from a font file.
This is only possible with font formats generated by the Font Converter.
Use external memory
If available use external memory to store your font files. The XBF and TTF formats are ideal for this purpose.
Performance
The best performance is offered by the c file font format. These formats are compiled with the application and can be linked into internal memory which allows fast access to the font data.
If the internal memory is small chose the XBF format to store fonts in external memory. This format requires only to file access to get the desired font data.