FontFamily Class | Font Class | FormattedTextArea Class | Fonts And Text  | com.cete.dynamicpdf.text Package | Programming with Generator for Java

Welcome > Generator > Programming > Fonts And Text > Font Families

Font families are a grouping of four styles of fonts (regular, bold, italic, and bold italic). These are used by the FormattedTextArea class to change fonts and specify styles. Five font families are included and accessed through static properties of the FontFamily class:

NOTE:The Symbol and Zapf Dingbats have the same font specified to all four font styles. New font families can be created by instantiating a FontFamily class and specifying the fonts for each style. These can include any of the 14 built-in fonts or TrueType fonts.

New font families can be created by passing four Font objects into a FontFamilies constructor. The name specified in the constructor is the name used to specify the font in an FormattedTextArea.

[Java]
    // Create four TrueType fonts.
    TrueTypeFont verdana = new TrueTypeFont("Verdana.ttf");
    TrueTypeFont verdanaBold = new TrueTypeFont("Verdanab.ttf");
    TrueTypeFont verdanaItalic = new TrueTypeFont("Verdanai.ttf");
    TrueTypeFont verdanaBoldItalic = new TrueTypeFont("Verdanaz.ttf");
    // Create a font family for Verdana.
    FontFamily verdanaFontFamily = new FontFamily("Verdana", verdana, verdanaBold,
                                                   verdanaItalic, verdanaBoldItalic);

NOTE: In order to use a created font family in an FormattedTextArea you must add it through the FormattedTextArea's getFontFaces property.

[Java]
    // Add the font family creaded above to an Formatted text area.
    formattedTextArea.getFontFaces().add(verdanaFontFamily);

See Also 

FontFamily Class | Font Class | FormattedTextArea Class | Fonts And Text  | com.cete.dynamicpdf.text Package | Programming with Generator for Java