GlyphTypeface
struct · ferroui-base · v0.5.0
struct GlyphTypeface
Represents a glyph typeface, providing access to font metrics, glyph mappings, and other font-related properties.
The GlyphTypeface class is used to encapsulate font data, including
metrics, character-to-glyph mappings, and supported OpenType features. It
supports platform-specific typefaces and applies optional font simulations
such as bold or oblique.
Members
newtry_createfamily_nametypographic_family_namefamily_namesface_namescharacter_to_glyph_mapmetricsweightstylestretchfont_simulationsglyph_countsupported_featuressupported_unicode_rangecode_page_coveragedesign_languagessupported_languagesdeclares_language_coveragesupports_scriptcan_shape_scriptplatform_typefacetext_shaper_typefacetry_get_horizontal_glyph_advancetry_get_horizontal_glyph_advancestry_get_vertical_glyph_advancetry_get_vertical_glyph_advancestry_get_glyph_metricstry_get_glyph_metrics_batchdispose
new
fn new(typeface: Rc<dyn IPlatformTypeface>, font_simulations: FontSimulations) -> Result<Rc<GlyphTypeface>, FontTableError>
Initializes a new instance of the GlyphTypeface class with the
specified platform typeface and font simulations.
This reads the font's metrics, names and character map from its
OpenType tables. Fails when a required table (cmap, maxp) is
missing or malformed.
try_create
fn try_create(typeface: Rc<dyn IPlatformTypeface>, font_simulations: FontSimulations) -> Option<Rc<GlyphTypeface>>
Creates a glyph typeface; a font whose tables cannot be read is logged
and gives None.
Internal upstream, where the Skia unit tests see it; public here so that the tests of the Skia crate reach it.
family_name
fn family_name(self: &Self) -> &str
Gets the family name of the font.
typographic_family_name
fn typographic_family_name(self: &Self) -> &str
Gets the typographic family name of the font.
family_names
fn family_names(self: &Self) -> &HashMap<Locale, String>
Gets a mapping of culture-specific family names, keyed by the locale of the culture
(the unknown locale und for the invariant culture).
face_names
fn face_names(self: &Self) -> &HashMap<Locale, String>
Gets a mapping of culture-specific face names, keyed by the locale of the culture
(the unknown locale und for the invariant culture).
character_to_glyph_map
fn character_to_glyph_map(self: &Self) -> &CharacterToGlyphMap
Gets a mapping of Unicode code points to glyph indices.
metrics
fn metrics(self: &Self) -> FontMetrics
Gets the font metrics associated with this font.
weight
fn weight(self: &Self) -> FontWeight
Gets the font weight.
style
fn style(self: &Self) -> FontStyle
Gets the font style.
stretch
fn stretch(self: &Self) -> FontStretch
Gets the font stretch.
font_simulations
fn font_simulations(self: &Self) -> FontSimulations
Gets the font simulation settings applied to the glyph typeface.
glyph_count
fn glyph_count(self: &Self) -> i32
Gets the number of glyphs held by this font.
supported_features
fn supported_features(self: &Self) -> &[OpenTypeTag]
Gets the supported OpenType features (GPOS first, then GSUB, without duplicates).
supported_unicode_range
fn supported_unicode_range(self: &Self) -> &UnicodeRange
Gets the Unicode ranges covered by the font's character map.
code_page_coverage
fn code_page_coverage(self: &Self) -> FontCodePageCoverage
Gets the code pages the font declares support for in its OS/2 table.
None when the font does not ship an OS/2 table (or only a version 0
table, which has no code page fields).
design_languages
fn design_languages(self: &Self) -> &[String]
BCP-47 tags of the languages the font is designed for (meta table dlng).
supported_languages
fn supported_languages(self: &Self) -> &[String]
BCP-47 tags of the languages the font supports (meta table slng).
declares_language_coverage
fn declares_language_coverage(self: &Self, culture: Option<&Locale>) -> bool
Whether the font's meta table declares coverage of the culture's language.
supports_script
fn supports_script(self: &Self, script: Script) -> bool
Whether the font declares (OS/2 Unicode range bit) or demonstrably has (probe codepoint) support for the script.
can_shape_script
fn can_shape_script(self: &Self, script: Script) -> bool
Whether the font can shape the script: simple scripts only need cmap coverage; complex scripts need the script's tag in GSUB or GPOS.
platform_typeface
fn platform_typeface(self: &Self) -> &Rc<dyn IPlatformTypeface>
Gets the platform-specific typeface associated with this font.
text_shaper_typeface
fn text_shaper_typeface(self: &Self) -> Rc<dyn ITextShaperTypeface>
Gets the typeface information used by the text shaper for this font.
Panics when no text shaper backend is registered.
try_get_horizontal_glyph_advance
fn try_get_horizontal_glyph_advance(self: &Self, glyph_index: u16) -> Option<u16>
Attempts to retrieve the horizontal advance width for the specified glyph.
try_get_horizontal_glyph_advances
fn try_get_horizontal_glyph_advances(self: &Self, glyph_indices: &[u16], advances: &mut [u16]) -> bool
Attempts to retrieve the horizontal advance widths for a batch of
glyphs. advances must be at least as long as glyph_indices.
try_get_vertical_glyph_advance
fn try_get_vertical_glyph_advance(self: &Self, glyph_index: u16) -> Option<u16>
Attempts to retrieve the vertical advance height for the specified glyph.
try_get_vertical_glyph_advances
fn try_get_vertical_glyph_advances(self: &Self, glyph_indices: &[u16], advances: &mut [u16]) -> bool
Attempts to retrieve the vertical advance heights for a batch of
glyphs. advances must be at least as long as glyph_indices.
try_get_glyph_metrics
fn try_get_glyph_metrics(self: &Self, glyph: u16) -> Option<GlyphMetrics>
Attempts to retrieve the metrics for the specified glyph.
try_get_glyph_metrics_batch
fn try_get_glyph_metrics_batch(self: &Self, glyph_indices: &[u16], metrics: &mut [GlyphMetrics]) -> bool
Attempts to retrieve the metrics for a batch of glyphs.
Panics when metrics is shorter than glyph_indices.
dispose
fn dispose(self: &Self)
Releases the platform typeface. Idempotent.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherFrom<&GlyphTypeface>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.