pub struct Typeface(/* private fields */);Expand description
A font loaded for text at one location in its design space, with the
family names, weight and style text chooses it by: Compose’s Typeface.
Clones share one load; two typefaces are equal when they draw the same
glyphs, from the same bytes at the same axis positions.
Implementations§
Source§impl Typeface
impl Typeface
Sourcepub fn from_bytes(bytes: impl Into<FontBytes>) -> Result<Self, TypefaceError>
pub fn from_bytes(bytes: impl Into<FontBytes>) -> Result<Self, TypefaceError>
Reads bytes as a typeface no family was declared for: its weight,
style and family names come from the font.
Sourcepub fn from_registered(
family: &FontFamily,
weight: FontWeight,
style: FontStyle,
bytes: impl Into<FontBytes>,
variations: &[([u8; 4], f32)],
) -> Result<Self, TypefaceError>
pub fn from_registered( family: &FontFamily, weight: FontWeight, style: FontStyle, bytes: impl Into<FontBytes>, variations: &[([u8; 4], f32)], ) -> Result<Self, TypefaceError>
Reads bytes as a typeface an app registered under family,
declaring weight and style for it, as a Compose Font(resId, weight, style) entry does: the declaration wins over the font’s own
values, and a variable font is instanced on its wght, ital and
slnt axes, so one file backs a whole family. The explicit
variations then win over the declared positions; a variation of an
axis the font lacks, or outside that axis’s range, fails.
Sourcepub fn family_names(&self) -> &[String]
pub fn family_names(&self) -> &[String]
The family names the font’s name table gives it, typographic family
first.
Sourcepub fn registered_family(&self) -> Option<FontFamilyKey>
pub fn registered_family(&self) -> Option<FontFamilyKey>
The family the typeface was registered under, None for one read
with Typeface::from_bytes.
Sourcepub fn weight(&self) -> FontWeight
pub fn weight(&self) -> FontWeight
The weight text chooses the typeface by.
Sourcepub fn is_color(&self) -> bool
pub fn is_color(&self) -> bool
Whether the font draws glyphs in color (a COLR, CBDT, sbix or
SVG table), as emoji fonts do.
Sourcepub fn synthesis(
&self,
weight: FontWeight,
style: FontStyle,
synthesis: FontSynthesis,
) -> Synthesis
pub fn synthesis( &self, weight: FontWeight, style: FontStyle, synthesis: FontSynthesis, ) -> Synthesis
What Compose synthesizes for text in weight and style drawn with
this typeface, as synthesis allows: a bold for a weight of 600 or
more when the typeface draws none that heavy, and an italic when it
draws none.
Sourcepub fn variations(&self) -> &[([u8; 4], f32)]
pub fn variations(&self) -> &[([u8; 4], f32)]
The axis positions the typeface is instanced at, sorted by tag.
Sourcepub fn content_hash(&self) -> u64
pub fn content_hash(&self) -> u64
A hash of the font’s bytes and its axis positions: equal for two loads of one instance.
Sourcepub fn units_per_em(&self) -> u16
pub fn units_per_em(&self) -> u16
The font’s design units in an em.
Sourcepub fn line_metrics(&self) -> LineMetrics
pub fn line_metrics(&self) -> LineMetrics
The font’s line metrics at the instance, in design units: the
typographic line when the font asks for it with USE_TYPO_METRICS,
otherwise the hhea line, as Skia and FreeType read them.
Sourcepub fn decoration_metrics(&self) -> DecorationMetrics
pub fn decoration_metrics(&self) -> DecorationMetrics
Where the font draws an underline and a line through its text, in
design units: its post underline and OS/2 strikeout, or Skia’s
defaults for a font without them.