8.2. Font families and font styles

All graph objects that uses text allows you to specify the font to be used by calling a SetFont() method and specifying three parameters.

  1. The font family. This could for example be "Arial", "Times roman" for TTF fonts or "Bitmap font medium size" when using bit-mapped fonts. The font family is specified by using a symbolic constant that starts with the prefix "FF_" (for Font Family). A list of all supported font families are shown in Table 8.2.

  2. The font style. This specifies if the font should be emphasized as italic, bold, or bold-italic. By default all fonts are rendered with the "normal" style. The fonts style is specified with a symbolic constant that starts with the prefix "FS_" (for Font Style). The supported font styles are:

    Table 8.1. Supported Font Styles

    Font style specifierDescription
    FS_NORMALNormal font style
    FS_BOLDBold font style
    FS_ITALICItalic font style
    FS_BOLDITALICBold + Italic style for font families that support this


    Please note that not all font families support all available styles.

  3. The font size. This is specified as an integer and depicts the size of the font given in typographic points (pt).

Table 8.2. Supported Latin Font family specifiers

Font family nameTypeCommentBoldItalicBI
FF_FONT0BitmapA very small font
FF_FONT1BitmapA medium sized font
FF_FONT2BitmapThe largest bit mapped font
FF_ARIALTTFArial font
FF_VERDANATTFVerdana font
FF_COURIERTTFFixed pitched Courier new font
FF_BOOKTTFBookman
FF_COMICTTFComic sans 
FF_TIMESTTFTimes New Roman
FF_GEORGIATTFGeorgia
FF_TREBUCHETTFTrebuche
FF_VERATTFGnome Vera font. All Vera family fonts are available from http://www.gnome.org/fonts/
FF_VERAMONOTTFGnome Vera Mono font
FF_VERASERIFTTFGnome Vera Serif font 
FF_DV_SANSSERIFTTFDejaVu Font family. The DejaVu fonts are modifications of the Bitstream Vera fonts designed to extend this original for greater coverage of Unicode, as well as providing more styles. These fonts are available from http://dejavu-fonts.org/
FF_DV_SANSSERIFMONOTTFDejaVu Font family.
FF_DV_SANSSERIFCONDTTFDejaVu Font family.
FF_DV_SERIFTTFDejaVu Font family.
FF_DV_SERIFCONDTTFDejaVu Font family.
FF_CHINESE, FF_BIG5TTF

Chinese font (both symbolic names can be used).

The actual font file name used for the Chinese font is "bkai00mp.ttf". The name of this file can be changed in the define CHINESE_TTF_FONT available in the library file jpgraph_ttf.inc.php

FF_SIMSUNTTF

Chinese font.

The actual font file name is "simsun.ttc"

FF_MINCHOTTF

Japanese font.

The actual font file name is "ipam.ttf"

FF_PMINCHOTTF

Japanese font.

The actual font file name is "ipamp.ttf"

FF_GOTHICTTF

Japanese font.

The actual font file name is "ipag.ttf"

FF_PGOTHICTTF

Japanese font.

The actual font file name is "ipagp.ttf"

FF_DAVIDTTF

Hebrew font.

The actual font file name is "DAVIDNEW.TTF"

FF_MIRIAMTTF

Hebrew font.

The actual font file name is "MRIAMY.TTF"

FF_AHRONTTF

Hebrew font.

The actual font file name is "ahronbd.ttf"


Note

Depending on what versions of the DejaVu fonts are installed on the system there are two naming conventions for the font files in common practice. The library will try both naming convention to see if it can find the font files.

In Figure 8.1 all latin fonts are shown.

Figure 8.1. List of all latin TTF fonts. (listfontsex1.php)

List of all latin TTF fonts. (listfontsex1.php)