Font Converter
Fonts which can be used with emWin should be defined either as GUI_FONT structures in C or should exist as system independent font data. If using C files the structures - or rather the font data which is referenced by these structures - can be rather large. It is very time-consuming and inefficient to generate these fonts manually. We therefore recommend using FontConvert, which automatically generates C files from fonts.
The font converter is an easy to use Windows program. Simply load an installed Windows font into the program, edit it if you want or have to, and save it. The C file may then be compiled, allowing the font to be shown on your display with emWin on demand. The following is a sample screen shot of the font converter with a font loaded in normal (standard) mode:
Using the font converter
The basic procedure for using the font converter for creating an emWin font file from an installed Windows font is illustrated below:
|
Step 1: Start the application. In this example, a font is to be generated in extended mode and with 16-bit Unicode encoding. (The antialiasing option is irrelevant here since an antialiased mode was not selected.) |
![]() |
| Step 2: Specify font options. In this example, a regular-style, 16-pixel Arial font is chosen (Note 1). Click OK. |
![]() |
| Step 3: Edit the font as necessary. For more information please refer to the user's manual. |
![]() |
| Step 4: Save the font as a "C" file. Choose File/Save As. Select the desired format of the font data file, "C" file, system independent font or external bitmap font. Select a destination and a name for the font file. Click Save. The font converter will create a separate file in the specified destination, containing the currently loaded font data. |
![]() |
Note 1:
The font height in the font converter is given in pixels, whereas most of other PC applications use the point size for specifying the font size. The font converter uses the operating system for getting the desired font resource. Please note that the font mapper of the operating system is not able to create each font in each desired pixel height. In these cases the font mapper of the operating system creates the nearest possible pixel height. This is not a bug of the font converter.
Font generation options dialog
| After starting the program or when choosing the menu point File/New, the following dialog automatically occurs: The selections made here will determine the output mode of the generated font, how it is to be encoded, and how it will be antialiased (if an antialiased output mode is selected). | ![]() |
Type of font to generate
The following shows the available font types to be created with the bitmap converter.
Standard
Creates a 1 bit per pixel font without antialiasing.
Antialiased, 2bpp
Creates an antialiased font using 2 bits per pixel.
Antialiased, 4bpp
Creates an antialiased font using 4 bits per pixel.
Extended
Creates a non antialiased 1 bit per pixel font with extended character information. This type of font is required for applications which need support for compound characters like used in Thai language.
Extended, framed
Creates a non antialiased 1 bit per pixel font with extended character information with a surrounding frame. A framed font is always drawn in transparent mode regardless of the current settings. The character pixels are drawn in the currently selected foreground color and the frame is drawn in background color. For more details please refer to the emWin user manual.
Extended, antialiased, 2bpp
Creates an antialiased 2 bit per pixel font with extended character information. Each character has the same height and its own width. The pixel information is saved with 2bpp antialiasing information and covers only the areas of the glyph bitmaps.
Extended, antialiased, 4bpp
Creates an antialiased 4 bit per pixel font with extended character information. Each character has the same height and its own width. The pixel information is saved with 4bpp antialiasing information and covers only the areas of the glyph bitmaps.
Encoding
16 Bit UNICODE
With Unicode encoding, you have access to all characters of a font. Windows font files contain a maximum of 65536 characters. All character codes of the C file are the same as those in the Windows font file.
8 Bit ASCII + ISO 8859
This encoding mode includes the ASCII codes (0x20 - 0x7F) and the ISO 8859 characters
(0xA0 - 0xFF).
8/16 Bit SHIFT JIS
Shift JIS (Japanese Industry Standard) enables mapping from Unicode to Shift JIS in accordance with the Unicode standard 2. For example, the Katakana letter .KU. is shifted from its Unicode value of 0x30AF to the Shift JIS value of 0x834E, the Kanji character 0x786F is shifted to 0x8CA5 and so on.
Antialiasing
You can choose between two ways of antialiasing. This choice only applies when an antialiased font type has been selected.
Using OS
The operating system is used to do the antialiasing. The resulting characters appear exactly the same as in any other windows application where antialiased characters
are displayed.
Internal
The internal antialiasing routines of the font converter are used to do the antialiasing.
Font Dialog
| After clicking OK in the Font generation options dialog box, a second dialog is displayed as follows: | ![]() |
After clicking OK in the Font generation options dialog box, a second dialog is displayed
as follows:
This is where the font to be converted into a C file is selected. Be sure that you do not violate any copyright laws by converting a font with the font converter.
Font, Font Style, and Size
These menus are used to select the particular font to be converted. The size of the font is specified in pixels.
Script
The Script box is used to select the character set which should be mapped down from Unicode into the first 256 characters in accordance with ISO 8859. It only applies when using the 8 Bit ASCII + ISO 8859 encoding mode.
Unit of Size
This option button can be used to set .Points. or .Pixels. as measuring unit. Please note that emWin does not know something about the unit .Points. whereas most of other PC applications use the point size for specifying the font size. The font converter uses the operating system for getting the desired font resource. Please note that the font mapper of the operating system is not able to create each font in each desired pixel height. In these cases the font mapper of the operating system creates the nearest possible pixel height. This is not a bug of the font converter.
User Interface
After clicking OK in the Font dialog box, the main user interface of the font converter appears, loaded with the previously selected font. You may convert the font into a C file immediately if you wish or edit its appearance first. The font converter is divided into two areas. In the upper area, all font characters appear scaled 1:1 as they will be displayed on your target device. Disabled characters are shown with a gray background. Per default all character codes which are not included in the chosen font are disabled. For example, many fonts do not include character codes from 0x00 to 0x1F and 0x7F to 0x9F, so these codes are grayed. The current character is displayed in a magnified scale on the left side of the lower area. Additional information about the font and the current character can be seen on the right side. If you want to modify the character data, you must first activate the lower area, either by pressing the <TAB> key or by simply clicking in the area.
Saving the font
The font converter can create C font files or system independent font data files. For details about the SIF format please refer to the emWin documentation.
Creating a C file
When you are ready to generate a C file, simply select File/Save As from the font converter menu, specify a destination and name for the file, choose the C file format and click Save. A C file will automatically be created. The default setting for the filename is built by the name of the source font and the current height in pixels. In antialiasing modes, .AA. is used as a postfix. For example, if the name of the source font is "Example" and the font is in an antialiased mode with a pixel height of 10, the default filename would be Example10AA.c. If you keep this default name when generating a C file, the resulting name of the font will be GUI_FontExample10AA.c.
Creating a System Independent Font (SIF)
When you are ready to generate the file, simply select File/Save As from the font converter menu, specify a destination and name for the file, choose the System independent font format and click Save. A system independent font file will automatically be created. This file does not contain C structures which can be compiled with emWin but binary font data, which can be used as described in the current emWin documentation.
Creating an External Binary Font (XBF)
When you are ready to generate the file, simply select File/Save As from the font converter menu, specify a destination and name for the file, choose the External binary font format and click Save. An external binary font file will automatically be created.
This file does not contain C structures which can be compiled with emWin but binary font data, which can be used as described in the current emWin documentation.
Modifying an existing C font file
The font converter is able to open existing font files and to modify their font data. The tool can only open C font files generated by the font converter. If the C font files have been modified manually, it can not be guaranteed, that they can be opened by the font converter.
| Step 1: Start the application. The font converter is opened and automatically displays the Font generation options dialog box. Press CANCEL. |
![]() |
| Step 2: Use the command ‘FileLoad C file’. Select the desired “C” font file to be opened and click OK. |
![]() |
Pattern Files
If you need to create fonts with a special set of characters (often for displaying a specific text), it can be very time consuming to enable every character by hand. In these cases, pattern files can be used to enable your character codes. A pattern file is nothing but a simple text file which contains the characters to be included in the font file. It can be used by FontConvert to enable only the characters you need.
Supported output modes of fonts
There are three modes supported by FontConvert: standard, 2-bit antialiased and 4-bit antialiased. If you are using a black and white LCD display, only the standard mode makes sense. If using a grayscale or color display, it is possible to improve the appearance of a font through antialiasing.
Antialiasing smoothes curves and diagonal lines by blending the background color with that of the foreground. The higher the number of shades used between background and foreground colors, the better the antialiasing result. The general purpose of using antialiased fonts is to improve the appearance of text. While the effect of using high-quality antialiasing will be more visually pleasing than low-quality, computation time and memory consumption will increase proportionally. Low-quality (2bpp) fonts require twice the memory of nonantialiased (1bpp) fonts; high-quality (4bpp) fonts require four times the memory The following table shows the difference between the modes by displaying the magnified character C in each:
| Font type | Black on white | White on black |
|---|---|---|
| Standard (no antialiasing) 1 bpp 2 shades |
![]() |
![]() |
| Low-quality (antialiased) 2 bpp 4 shades |
![]() |
![]() |
| High-quality (antialiased) 4 bpp 16 shades |
![]() |
![]() |
Table of command line options
The following table shows the available command line options:
| create<FONTNAME>,<STYLE>, <HEIGHT>,<TYPE>,<ENCODING> |
Create font: <FONTNAME> Name of font to be used <STYLE> REGULAR – Creates a normal font BOLD – Creates a bold font <HEIGHT> Height in pixels of font to be created <TYPE> STD – Standard 1bpp font AA2 – Antialiased font (2bpp) AA4 – Antialiased font (4bpp) EXT – Extended font <ENCODING> UC16 – 16 bit Unicode encoding ISO8859 – 8 bit ASCII + ISO8859 JIS – Shift JIS |
| enable<FIRST-LAST>,<STATE> | Enables or disables the given range of charac- ters: <FIRST-LAST> Specifies the range of characters. <STATE> 1 – Enables the given range. 0 – Disables the given range. |
| exit | Finish application after job. |
| readpattern<FILENAME> | Reads a pattern file: <FILENAME> Name of the pattern file to be read. |
| saveas<FILENAME>,<TYPE> | Saves the font data as 'C' file or 'SIF' font file: <FILENAME> File name to be used <TYPE> C – Saves the data as ‘C’ file. SIF – Saves as System independent font file. |
| ? | Showa all available commands |
Example C code
/* C-file generated by Font converter for emWin version 3.04 Compiled: Dec 13 2005 at 12:51:50 C-file created: Dec 21 2005 at 12:42:57 Copyright (C) 1998-2005 Segger Microcontroller Systeme GmbH www.segger.com Solutions for real time microcontroller applications Source file: Sample10.c Font: Arial Height: 10 */ #include "GUI.H" #ifndef GUI_CONST_STORAGE #define GUI_CONST_STORAGE const #endif /* The following line needs to be included in any file selecting the font. A good place would be GUIConf.H */ extern GUI_CONST_STORAGE GUI_FONT GUI_FontSample10; /* Start of unicode area*/
GUI_CONST_STORAGE unsigned char acFontSample10_0041[10] = { /* code 0041 */
________,
___X____,
__X_X___,
__X_X___,
__X_X___,
_X___X__,
_XXXXX__,
X_____X_,
X_____X_,
________};
GUI_CONST_STORAGE unsigned char acFontSample10_0061[10] = { /* code 0061 */
________,
________,
________,
_XXX____,
X___X___,
_XXXX___,
X___X___,
X__XX___,
_XX_X___,
________};
GUI_CONST_STORAGE GUI_CHARINFO GUI_FontSample10_CharInfo[2] = {
{ 8, 8, 1, acFontSample10_0041 } /* code 0041 */
,{ 6, 6, 1, acFontSample10_0061 } /* code 0061 */
};
GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontSample10_Prop2 = {
97 /* first character */
,97 /* last character */
,&GUI_FontSample10_CharInfo[1] /* address of first character */
,(GUI_CONST_STORAGE GUI_FONT_PROP*)0 /* pointer to next GUI_FONT_PROP */
};
GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontSample10_Prop1 = {
65 /* first character */
,65 /* last character */
,&GUI_FontSample10_CharInfo[0] /* address of first character */
,&GUI_FontSample10_Prop2 /* pointer to next GUI_FONT_PROP */
};
GUI_CONST_STORAGE GUI_FONT GUI_FontSample10 = {
GUI_FONTTYPE_PROP /* type of font */
,10 /* height of font */
,10 /* space of font y */
,1 /* magnification x */
,1 /* magnification y */
,&GUI_FontSample10_Prop1
};
Font Converter
Head office Germany
US office 












