OpenType fonts and TrueType fonts can be used by creating an OpenTypeFont object and specifying the path to the OpenType or TrueType font file in the constructor. You can then use that font anywhere a font is specified, such as in the constructors of the Label and TextArea classes.
[Java]
// Create a OpenType font class.
OpenTypeFont openTypeFont = new OpenTypeFont( "verdana.otf" );
// Use the OpenType font in a text area Page Element.
page.getElements().add( new TextArea("Text", 0, 0, 200, 12, openTypeFont, 12 ) );
By default, only the characters of an OpenType font that are used will be embedded in the PDF document. This greatly reduces the size of the resulting PDF. The OpenTypeFont however also contains an Embed property that when set to a value of true will embed the entire font information in the PDF regardless of the number of characters used on the PDF. Fully embedding fonts is one requirement that must be fulfilled to achieve PDF/A documents. It has however the option of embedding the entire font.
NOTE: Helvetica is equivalent to the Arial TrueType font included on Windows systems, and Times is equivalent to the Times New Roman TrueType font included on Windows systems. It is much more efficient to use the equivalent core fonts whenever possible.
When using the same OpenType font more than once within the same document, it is important to create the OpenTypeFont object only once, and use it wherever needed. Doing this will prevent the font from being embedded in the document multiple times.
When an OpenTypeFont object is initialized, resources are required to parse the font. For fonts that are to be used across multiple documents, the OpenTypeFont class can be initialized and set to a static member variable. This static member variable can then be used anywhere the font is required.