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:
family
The 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.
size
A floating-point value that specifies the text size.
Optional attributes
The following attributes are optional:
color
- The 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). letterSpacing
- The 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.
slant
- Whether to use a
NORMAL
font slant (default) or anITALIC
slant. width
An 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_CONDENSED
andEXTRA_CONDENSED
use the "condensed-light" variant.CONDENSED
uses the "condensed" variant.SEMI_CONDENSED
uses the "condensed-medium" variant.SEMI_EXPANDED
,EXPANDED
,EXTRA_EXPANDED
, andULTRA_EXPANDED
each use the "normal" variant.
weight
An 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:
THIN
uses a font weight of100
.ULTRA_LIGHT
uses a font weight of150
.EXTRA_LIGHT
uses a font weight of200
.LIGHT
uses a font weight of300
.MEDIUM
uses a font weight of500
.SEMI_BOLD
uses a font weight of600
.ULTRA_BOLD
uses a font weight of750
.EXTRA_BOLD
uses a font weight of800
.BLACK
uses a font weight of900
.EXTRA_BLACK
uses a font weight of1000
.
Inner elements
The Font
element can contain the following inner elements: