Documentation

The Java™ Tutorials
Hide TOC
Font Concepts字体概念
Trail: 2D Graphics
Lesson: 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.本节向您介绍Font类,该类支持详细字体信息的规范和复杂排版功能的使用。

A Font object represents an instance of a font face from the collection of font faces available on the system. Font对象表示系统上可用字体集合中的字体实例。Examples of common font faces include Helvetica Bold and Courier Bold Italic. 常见字体包括Helvetica粗体和Courier粗体斜体。Three names are associated with a Font object: its logical name, family name, and font face name:Font对象关联了三个名称:逻辑名称、字体系列名称和字体名称:

You can access information about a Font through the getAttributes method. 您可以通过getAttributes方法访问有关Font的信息。A Font object's attributes include its name, size, transform, and font features such as weight and posture.Font对象的属性包括其名称、大小、变换以及字体特征(如重量和姿势)。

A LineMetrics object encapsulates the measurement information associated with a Font, such as its ascent, descent, and leading:LineMetrics对象封装与字体相关联的度量信息,例如Font的上升、下降和前导:

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. 您可以通过getAscentgetDescentgetLeading方法访问这些行度量。You can also access information about a Font object's height, baseline, and underline and strikethrough characteristics through the LineMetrics class.您还可以通过LineMetrics类访问有关Font对象的高度、基线、下划线和删除线特征的信息。


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