Fonts and FontMetrics

The AWT includes two classes that support font manipulation: Font and FontMetrics.

The Font class provides a basic set of fonts and font styles. Because Java is platform independent, fonts such as Helvetica, Times Roman, and so on are always mapped to an available font on the native platform.

The FontMetrics class allows access to the metrics associated with a particular font, including the font's height, leading, ascent and descent, the width of a specified string, etc.

Fonts

With the advent of the Java 2D Api, the Font class has been extended a great deal. In addition, the 2D Api provides a java.awt.font package containing advanced support for fonts, glyphs, and ligatures. Our discussion here will focus on the aspects ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.