# GlyphTypeface

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/struct-glyphtypeface/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L38)

## Members

- [`new`](#function-new)
- [`try_create`](#function-try_create)
- [`family_name`](#function-family_name)
- [`typographic_family_name`](#function-typographic_family_name)
- [`family_names`](#function-family_names)
- [`face_names`](#function-face_names)
- [`character_to_glyph_map`](#function-character_to_glyph_map)
- [`metrics`](#function-metrics)
- [`weight`](#function-weight)
- [`style`](#function-style)
- [`stretch`](#function-stretch)
- [`font_simulations`](#function-font_simulations)
- [`glyph_count`](#function-glyph_count)
- [`supported_features`](#function-supported_features)
- [`supported_unicode_range`](#function-supported_unicode_range)
- [`code_page_coverage`](#function-code_page_coverage)
- [`design_languages`](#function-design_languages)
- [`supported_languages`](#function-supported_languages)
- [`declares_language_coverage`](#function-declares_language_coverage)
- [`supports_script`](#function-supports_script)
- [`can_shape_script`](#function-can_shape_script)
- [`platform_typeface`](#function-platform_typeface)
- [`text_shaper_typeface`](#function-text_shaper_typeface)
- [`try_get_horizontal_glyph_advance`](#function-try_get_horizontal_glyph_advance)
- [`try_get_horizontal_glyph_advances`](#function-try_get_horizontal_glyph_advances)
- [`try_get_vertical_glyph_advance`](#function-try_get_vertical_glyph_advance)
- [`try_get_vertical_glyph_advances`](#function-try_get_vertical_glyph_advances)
- [`try_get_glyph_metrics`](#function-try_get_glyph_metrics)
- [`try_get_glyph_metrics_batch`](#function-try_get_glyph_metrics_batch)
- [`dispose`](#function-dispose)

<a id="function-new"></a>

### new

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L85)

<a id="function-try_create"></a>

### try_create

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L303)

<a id="function-family_name"></a>

### family_name

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

Gets the family name of the font.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L325)

<a id="function-typographic_family_name"></a>

### typographic_family_name

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

Gets the typographic family name of the font.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L330)

<a id="function-family_names"></a>

### family_names

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L336)

<a id="function-face_names"></a>

### face_names

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L342)

<a id="function-character_to_glyph_map"></a>

### character_to_glyph_map

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

Gets a mapping of Unicode code points to glyph indices.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L347)

<a id="function-metrics"></a>

### metrics

```rust
fn metrics(self: &Self) -> FontMetrics
```

Gets the font metrics associated with this font.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L365)

<a id="function-weight"></a>

### weight

```rust
fn weight(self: &Self) -> FontWeight
```

Gets the font weight.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L370)

<a id="function-style"></a>

### style

```rust
fn style(self: &Self) -> FontStyle
```

Gets the font style.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L375)

<a id="function-stretch"></a>

### stretch

```rust
fn stretch(self: &Self) -> FontStretch
```

Gets the font stretch.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L380)

<a id="function-font_simulations"></a>

### font_simulations

```rust
fn font_simulations(self: &Self) -> FontSimulations
```

Gets the font simulation settings applied to the glyph typeface.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L385)

<a id="function-glyph_count"></a>

### glyph_count

```rust
fn glyph_count(self: &Self) -> i32
```

Gets the number of glyphs held by this font.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L390)

<a id="function-supported_features"></a>

### supported_features

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L395)

<a id="function-supported_unicode_range"></a>

### supported_unicode_range

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L400)

<a id="function-code_page_coverage"></a>

### code_page_coverage

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L408)

<a id="function-design_languages"></a>

### design_languages

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L413)

<a id="function-supported_languages"></a>

### supported_languages

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L418)

<a id="function-declares_language_coverage"></a>

### declares_language_coverage

```rust
fn declares_language_coverage(self: &Self, culture: Option<&Locale>) -> bool
```

Whether the font's `meta` table declares coverage of the culture's language.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L423)

<a id="function-supports_script"></a>

### supports_script

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L468)

<a id="function-can_shape_script"></a>

### can_shape_script

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L496)

<a id="function-platform_typeface"></a>

### platform_typeface

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

Gets the platform-specific typeface associated with this font.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L535)

<a id="function-text_shaper_typeface"></a>

### text_shaper_typeface

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L542)

<a id="function-try_get_horizontal_glyph_advance"></a>

### try_get_horizontal_glyph_advance

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L563)

<a id="function-try_get_horizontal_glyph_advances"></a>

### try_get_horizontal_glyph_advances

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L569)

<a id="function-try_get_vertical_glyph_advance"></a>

### try_get_vertical_glyph_advance

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L577)

<a id="function-try_get_vertical_glyph_advances"></a>

### try_get_vertical_glyph_advances

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L583)

<a id="function-try_get_glyph_metrics"></a>

### try_get_glyph_metrics

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

Attempts to retrieve the metrics for the specified glyph.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L621)

<a id="function-try_get_glyph_metrics_batch"></a>

### try_get_glyph_metrics_batch

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L665)

<a id="function-dispose"></a>

### dispose

```rust
fn dispose(self: &Self)
```

Releases the platform typeface. Idempotent.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/glyph_typeface.rs#L792)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-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](/docs/0.5.0/api/).
