Training Index 2D text Guide Lesson: Using Fonts Author: Monica PawlanSeptember 1998 translation: Cherami Liumin November 2001 [Contents] [next lesson >>] word on the nature of art is a simple text fonts. The font defines the size of the text string and the overall look. This lesson describes how to create fonts using enhanced Java.awt.Font classes. The next lesson explains how to create and draw art characters using fonts.
What is a font? Find available font creation and derived font exercises
What is a font? The font is a set of character types with a point size and appearance. For example, all 10 points Helvetica English characters and symbols form a font. The fonts used in text define specific appearance, size, and model (black body, hemodynamic or general). How does the font define a specific look? The font is created from the glyphs, a glyph is a bit image image, which defines the appearance of characters and symbols in the font. The fonts of the same font family have similar appearance because they created the same shape. Similarly, different font families use different glyphs to distinguish the appearance of each other. A font family is not only composed of fonts with similar appearance, but also different sizes and patterns. Helvetica 10 Point Black and Helvetica 12 Point Body is two different fonts in the same family, while Times Roman 8-point black body and Times Roman 10 point ordinary body is two different fonts of another family. Finding the available font In order to use a font, you need to create a font object, and in order to do this, you need to know what font available in the system and their name. The font has a logical name, family name and font name. The logical name is the name of the specific font being mapped to the platform.
In order to get the logical name of a Font object, call java.awt.font.get name. The family name is the name of the font family, which determines the typographic pattern through different appearances, such as Helvetica or Times Roman.
In order to get a family name of a Font object, call java.awt.font.getfamily. The font name represents a specific font in the family, such as Helvetica Bold.
In order to get a font object name, call java.awt.font.getFontName, in order to determine which fonts available, call java.awt.graphicsenvironment.GetAllFonts.
The easiest way to create and derive fonts Creating a font is to specify the font name, size, and style. Once you have a Font object, you can derive any new Font object on the existing font and specify new size, style, transform, and rotate (position, tilt, zoom, or rotation) or attribute mapping. Font Boldfont = New Font ("Helvetica", Font.Bold, 12);
Font ItalicDerived =
BoldFont.deriveFont (Font.Italic, 12);
Font Plaholderived =
Boldfont.deriveFont (Font.Plain, 14);
Once you have a font, you can use it to create a TextLayout object and draw art characters, which is the topic of the next lesson.