TextAttribute.Font Property

Definition

Attribute key used to provide the font to use to render text.

[Android.Runtime.Register("FONT")]
public static Java.Awt.Font.TextAttribute? Font { get; }
[<Android.Runtime.Register("FONT")>]
static member Font : Java.Awt.Font.TextAttribute

Property Value

Attributes

Remarks

Attribute key used to provide the font to use to render text.

The default value is null, indicating that normal resolution of a Font from attributes should be performed.

TextLayout and AttributedCharacterIterator work in terms of Maps of TextAttributes. Normally, all the attributes are examined and used to select and configure a Font instance. If a FONT attribute is present, though, its associated Font will be used. This provides a way for users to override the resolution of font attributes into a Font, or force use of a particular Font instance. This also allows users to specify subclasses of Font in cases where a Font can be subclassed.

FONT is used for special situations where clients already have a Font instance but still need to use Map-based APIs. Typically, there will be no other attributes in the Map except the FONT attribute. With Map-based APIs the common case is to specify all attributes individually, so FONT is not needed or desireable.

However, if both FONT and other attributes are present in the Map, the rendering system will merge the attributes defined in the Font with the additional attributes. This merging process classifies TextAttributes into two groups. One group, the 'primary' group, is considered fundamental to the selection and metric behavior of a font. These attributes are FAMILY, WEIGHT, WIDTH, POSTURE, SIZE, TRANSFORM, SUPERSCRIPT, and TRACKING. The other group, the 'secondary' group, consists of all other defined attributes, with the exception of FONT itself.

To generate the new Map, first the Font is obtained from the FONT attribute, and <em>all</em> of its attributes extracted into a new Map. Then only the <em>secondary</em> attributes from the original Map are added to those in the new Map. Thus the values of primary attributes come solely from the Font, and the values of secondary attributes originate with the Font but can be overridden by other values in the Map.

Java documentation for java.awt.font.TextAttribute.FONT.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to