ChartDirector Ver 3.0 (C++ Edition)

Font Specification


Font File

In ChartDirector, a font can be specified by specifying the file name that contains the font. For example, under the Windows platform, the "Arial" font is specified as "arial.ttf", while the "Arial Bold" font is specified as "arialbd.ttf".

ChartDirector also supports several special keywords for specifying the fonts indirectly. The actual font file name is looked up from a font table based on the keywords. The keywords are as follows:

KeywordsDescription
"normal" This default normal font, which is the same as the first font in the font table. ChartDirector will draw text using this font unless otherwise specified.
"bold" The default bold font, which is the same as the second font in the font table.
"italic" The default italic font, which is the same as the third font in the font table.
"boldItalic" The default bold-italic font, which is the same as the fourth font in the font table.
"font{N}" The (N + 1)th font in the font table (the first font is "font0").

The default font table contains 4 fonts. They are "arial.ttf" for "normal", "arialbd.ttf" for "bold", "ariali.ttf" for "italic" and "arialbi.ttf" for "boldItalic". The font table can be modified using BaseChart.setFontTable or DrawArea.setFontTable.

The advantages of using fonts in the font table is that you can defined and modified all fonts in your chart in one place.

ChartDirector on Windows does not come with any font files. It relies on the operating system's font files in the "%systemroot%\Fonts" directory, where %systemroot% is the operating system installation directory. To see what fonts are installed in your operating system and their file names, use the File Explorer to view that directory.

ChartDirector on Linux/FreeBSD/Solaris assumes the fonts files are in the "fonts" directory under the directory where the ChartDirector shared object "libchartdir.so" is installed. ChartDirector on Linux/FreeBSD/Solaris comes with a number of font files in the "fonts" directory.

To keep the download size small, ChartDirector on Linux/FreeBSD/Solaris only comes with some commonly used fonts. You may donwload additional fonts from the Internet. In particular, the Microsoft fonts at http://sourceforge.net/project/showfiles.php?group_id=34153&release_id=105355 is highly recommended. Please refer to http://www.microsoft.com/typography/faq/faq8.htm on how you could use the fonts legally in your system.

ChartDirector supports True Type fonts (.ttf), Type 1 fonts (.pfa and .pfb), Windows bitmap fonts (.fon), and Portable Compiled Fonts (.pcf fonts). The PCF fonts are supported on Linux/FreeBSD/Solaris only, while the other fonts types are supported on both Windows and Linux/FreeBSD/Solaris.

If you want ChartDirector to search other directories for the font files, you may list the directories in an environment variable called "FONTPATH".

If you specify an absolute path name for the font file, ChartDirector will use the absolute path name and will not search other directories.

Font Index

In practice, most font files contain only one font. However, in theory, a font file may contain more than one font. In this case, the font index can be used to specify which font to use.

By default, the font index is 0, which means the first font in the font file will be used.

Font Size, Font Height and Font Width

The font size decides how big a font will appear in the image. The font size is expressed in a font unit called points. This is the same unit used in common word processors.

When you specify a font size, both the font height and font width will be scaled by the same factor. ChartDirector also supports using different point sizes for font height and font width to create special effects. For example, TextBox.setFontSize allows you to specify different font height and font width.

Font Color

This is the color to draw the font. (See Color Specification on how colors are represented in ChartDirector.)

Font Angle

This is the angle in degrees by which the font should be rotated anti-clockwise.

Vertical Layout

By default, text are laid out horizontally, with characters being drawn from left to right.

ChartDirector also supports vertical layout, with characters being drawn from top to bottom. For example, you may use BaseChart.addText to add text that are laid out vertically. Vertical layout is common for oriental languages such as Chinese, Japanese and Korean.