FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    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.

    Source

    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.

    Source

    family_name

    fn family_name(self: &Self) -> &str
    

    Gets the family name of the font.

    Source

    typographic_family_name

    fn typographic_family_name(self: &Self) -> &str
    

    Gets the typographic family name of the font.

    Source

    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).

    Source

    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).

    Source

    character_to_glyph_map

    fn character_to_glyph_map(self: &Self) -> &CharacterToGlyphMap
    

    Gets a mapping of Unicode code points to glyph indices.

    Source

    metrics

    fn metrics(self: &Self) -> FontMetrics
    

    Gets the font metrics associated with this font.

    Source

    weight

    fn weight(self: &Self) -> FontWeight
    

    Gets the font weight.

    Source

    style

    fn style(self: &Self) -> FontStyle
    

    Gets the font style.

    Source

    stretch

    fn stretch(self: &Self) -> FontStretch
    

    Gets the font stretch.

    Source

    font_simulations

    fn font_simulations(self: &Self) -> FontSimulations
    

    Gets the font simulation settings applied to the glyph typeface.

    Source

    glyph_count

    fn glyph_count(self: &Self) -> i32
    

    Gets the number of glyphs held by this font.

    Source

    supported_features

    fn supported_features(self: &Self) -> &[OpenTypeTag]
    

    Gets the supported OpenType features (GPOS first, then GSUB, without duplicates).

    Source

    supported_unicode_range

    fn supported_unicode_range(self: &Self) -> &UnicodeRange
    

    Gets the Unicode ranges covered by the font's character map.

    Source

    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).

    Source

    design_languages

    fn design_languages(self: &Self) -> &[String]
    

    BCP-47 tags of the languages the font is designed for (meta table dlng).

    Source

    supported_languages

    fn supported_languages(self: &Self) -> &[String]
    

    BCP-47 tags of the languages the font supports (meta table slng).

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    platform_typeface

    fn platform_typeface(self: &Self) -> &Rc<dyn IPlatformTypeface>
    

    Gets the platform-specific typeface associated with this font.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    try_get_glyph_metrics

    fn try_get_glyph_metrics(self: &Self, glyph: u16) -> Option<GlyphMetrics>
    

    Attempts to retrieve the metrics for the specified glyph.

    Source

    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.

    Source

    dispose

    fn dispose(self: &Self)
    

    Releases the platform typeface. Idempotent.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither
    • From<&GlyphTypeface>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.