6.1. Overview
In Java, text is expressed as a series of Unicode characters. Unicode is a standardized list of characters matched up with 16-bit character codes. The Unicode standard includes character codes for the characters that are used in most of the world's written languages. For more information, visit http://www.unicode.org/. Java uses 16-bit Unicode characters in its char type. Strings, furthermore, are an array of Unicode characters.
Rendering text is the task of finding shapes that correspond to characters and rendering the shapes on a drawing surface. In the 2D API, this is the job of Graphics2D, the rendering engine.
6.1.1. Fonts and Glyphs
The shapes that represent characters are called glyphs. Frequently there is a one-to-one correspondence between characters and glyphs, but not all the time. For example, the characters "f " and "i" each have a corresponding glyph. But sometimes, for aesthetic reasons, "f " and "i" together are represented by a single glyph, called a ligature. An example of a ligature is shown in Figure 6.1. Notice how the dot on the "i" has been combined with the ball on the "f " to create an efficient representation of the two characters.
Figure 6.1. A ligature is a single glyph representing two or more characters
Furthermore, different glyphs may be used for a single character depending on the character's context. This is true in Arabic writing, ...
Get Java 2D Graphics 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.