Trail: 2D Graphics
Lesson: Working with Text APIs
Font Concepts
Home Page > 2D Graphics > Working with Text APIs

Font Concepts

This section introduces you to the Font class, which supports the specification of detailed font information and the use of sophisticated typographic features.

A Font object represents an instance of a font face from the collection of font faces available on the system. Examples of common font faces include Helvetica Bold and Courier Bold Italic. Three names are associated with a Font object: its logical name, family name, and font face name:

You can access information about a Font through the getAttributes method. A Font objects's attributes include its name, size, transform, and font features such as weight and posture.

A LineMetrics object encapsulates the measurement information associated with a Font, such as its ascent, descent, and leading:

The following figure shows the position of the ascender line, baseline, and descender line:

Position of the ascender line, baseline, and descender line

This information is used to properly position characters along a line, and to position lines relative to one another. You can access these line metrics through the getAscentgetDescent, and getLeading methods. You can also access information about a Font objects's height, baseline, and underline and strikethrough characteristics through the LineMetrics class.


Problems with the examples? Try Compiling and Running the Examples: FAQs.
Complaints? Compliments? Suggestions? Give us your feedback.

Previous page: Working with Text APIs
Next page: Text Layout Concepts