Font families are a grouping of four styles of fonts (regular, bold, italic, and bold italic). These are used by the HtmlTextArea class to change fonts and specify styles. Five font families are included and accessed through static properties of the FontFamily class:
- FontFamily.getTimes() - Times Font Family
- FontFamily.getHelvetica() - Helvetica Family
- FontFamily.getCourier() - Courier Family
- FontFamily.getSymbol() - Symbol Family
- FontFamily.getZapfDingbats() - Zapf Dingbats Font Family
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 HtmlTextArea.
[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 HtmlTextArea you must add it through the HtmlTextArea's getFontFaces property.
[Java]
// Add the font family creaded above to an HTML text area.
htmlTextArea.getFontFaces().add(verdanaFontFamily);
See Also
FontFamily Class | Fonts And Text | | com.cete.dynamicpdf.text Package
