Provides rendering instructions for a specific text element.
Introduced in Wear OS 4.
Syntax
<Font family="string | SYNC_TO_DEVICE" size="float" color="argb-color | rgb-color" slant="NORMAL | ITALIC" letterSpacing="em-value" width="ULTRA_CONDENSED | EXTRA_CONDENSED | CONDENSED | SEMI_CONDENSED | NORMAL | SEMI_EXPANDED | EXPANDED | EXTRA_EXPANDED | ULTRA_EXPANDED" weight="THIN | ULTRA_LIGHT | EXTRA_LIGHT | LIGHT | NORMAL | MEDIUM | BOLD | SEMI_BOLD | ULTRA_BOLD | EXTRA_BOLD | BLACK | EXTRA_BLACK"> <!-- Inner elements consist of text decoration and text formatting options. Here, "Lower" is used as an example. --> <Lower ... /> </Font>
Attributes
The Font element has the following attributes. Some attributes are
required while others are optional.
Required attributes
The following attributes are required:
familyThe name of the font used for rendering the text. To use the same font family as the system, set this value to
SYNC_TO_DEVICE.To use a custom font, place the font file in
res/font/, using one of the following accepted font file extensions: TTF, OTF, TTC, or XML. Then, set this value to the name of the font file, excluding the extension at the end.If the font file cannot be resolved, the system font is used.
sizeA floating-point value that specifies the text size.
Optional attributes
The following attributes are optional:
colorThe color of the text. If provided, you must specify the color using either the ARGB format (
#ff000000= opaque black) or the RGB format (#000000= black).From version 4, this attribute is transformable.
letterSpacingThe space between letters, specified in EM units. The default value is 0. An example for slight expansion could be 0.05. Negative values tighten text.
slantWhether to use a
NORMALfont slant (default) or anITALICslant.widthAn enumeration of several hints for a font family variant to use. The default value is
NORMAL, which applies the "normal" variant of the font.The following list contains the other enumeration values and the respective font family variants that they use, if that variant is available for the font:
ULTRA_CONDENSEDandEXTRA_CONDENSEDuse the "condensed-light" variant.CONDENSEDuses the "condensed" variant.SEMI_CONDENSEDuses the "condensed-medium" variant.SEMI_EXPANDED,EXPANDED,EXTRA_EXPANDED, andULTRA_EXPANDEDeach use the "normal" variant.
weightAn enumeration of several possible font weights. The default value is
NORMAL, which applies a weight of400.The following list contains the other enumeration values and their respective font weights:
THINuses a font weight of100.ULTRA_LIGHTuses a font weight of150.EXTRA_LIGHTuses a font weight of200.LIGHTuses a font weight of300.MEDIUMuses a font weight of500.SEMI_BOLDuses a font weight of600.ULTRA_BOLDuses a font weight of750.EXTRA_BOLDuses a font weight of800.BLACKuses a font weight of900.EXTRA_BLACKuses a font weight of1000.
Inner elements
The Font element can contain the following inner elements: