
CHAPTER 15
Thejava.awt.font Package
The java.awt.font package contains classes and interfaces related to fonts; it is new
in Java 1.2. Note, however, that the Font class itself is part of the java.awt package.
This package contains low-level classes for obtaining information about the mea-
sur ements of font glyphs and lines of text. It also contains classes for the low-level
layout of text. LineMetrics and TextLayout ar e the two most important classes in this
package. Figure 15-1 shows the class hierarchy of this package.
Most programs can rely on the higher-level text display features of java.awt and
javax.swing and do not have to use this package.
FontRenderContext Ja va 1.2
java.awt.font
This class stores the information necessary to precisely measure the size of text. It is
used by a number of Font methods and also by TextLayout and LineBreakMeasurer. Although
FontRenderContext has a public constructor, it is mor e common to obtain a FontRenderCon-
text by calling the getFontRenderContext() method of a Graphics2D object.
public class FontRenderContext {
// Public Constructors
public FontRenderContext(java.awt.geom.AffineTransform tx, boolean isAntiAliased,
boolean usesFractionalMetrics);
// Protected Constructors
protected FontRenderContext();
// Property Accessor Methods (by property name)
public boolean isAntiAliased();
public java.awt.geom.AffineTransform getTransfor m();
// Public Instance Methods ...