Font families and font styles

Default TrueType Font

Prior to ver. 3.5, bitmap fonts are used by default which can specified from FF_FONT0 to FF_FONT2. From version 3.5, default fonts are now set to one of the open-source TrueType DejaVu font (FF_DV_SANSSERIF, DejaVuSans.ttf). This TrueType font is included in JpGraph source code (src/fonts), and there is no need to specify font for this one.

You can change default font family by changing FF_DEFAULT defined in You have to prepare your own font file as well in order to use another font.

If Freetype library is not usable in your PHP configuration, original BITMAP font will be used for compatibility.

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. Supported Latin Font family specifiers.

  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_COURIERTTFFixed pitched Courier new font
FF_COMICTTFComic sans 
FF_TIMESTTFTimes New Roman
FF_VERATTFGnome Vera font. All Vera family fonts are available from
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
FF_DV_SERIFTTFDejaVu Font family.

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


Chinese font.

The actual font file name is "simsun.ttc"


Japanese font.

The actual font file name is "ipam.ttf"


Japanese font.

The actual font file name is "ipamp.ttf"


Japanese font.

The actual font file name is "ipag.ttf"


Japanese font.

The actual font file name is "ipagp.ttf"


Hebrew font.

The actual font file name is "DAVIDNEW.TTF"


Hebrew font.

The actual font file name is "MRIAMY.TTF"


Hebrew font.

The actual font file name is "ahronbd.ttf"


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. List of all latin TTF fonts. (listfontsex1.php) all latin fonts are shown.

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

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