# Typeface

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

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

```rust
struct Typeface
```

Represents a typeface: a font family with a style, weight and stretch.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/typeface.rs#L9)

## Members

- [`new`](#function-new)
- [`with_style`](#function-with_style)
- [`from_name`](#function-from_name)
- [`from_name_with_style`](#function-from_name_with_style)
- [`default_typeface`](#function-default_typeface)
- [`font_family`](#function-font_family)
- [`style`](#function-style)
- [`weight`](#function-weight)
- [`stretch`](#function-stretch)
- [`glyph_typeface`](#function-glyph_typeface)
- [`normalize`](#function-normalize)

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

### new

```rust
fn new(font_family: FontFamily) -> Self
```

Creates a normal typeface of a font family.

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

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

### with_style

```rust
fn with_style(font_family: FontFamily, style: FontStyle, weight: FontWeight, stretch: FontStretch) -> Self
```

Creates a typeface.

Panics when `weight` is not positive.

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

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

### from_name

```rust
fn from_name(font_family_name: &str) -> Self
```

Creates a normal typeface from a font family name; an empty name gives
the default font family.

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

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

### from_name_with_style

```rust
fn from_name_with_style(font_family_name: &str, style: FontStyle, weight: FontWeight, stretch: FontStretch) -> Self
```

Creates a typeface from a font family name; an empty name gives the
default font family.

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

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

### default_typeface

```rust
fn default_typeface() -> Typeface
```

The default typeface: the default font family, normal style.

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

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

### font_family

```rust
fn font_family(self: &Self) -> &FontFamily
```

Gets the font family.

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

<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/typeface.rs#L71)

<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/typeface.rs#L76)

<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/typeface.rs#L81)

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

### glyph_typeface

```rust
fn glyph_typeface(self: &Self) -> Rc<GlyphTypeface>
```

Gets the glyph typeface.

Panics when the font manager cannot create one (C# throws
`InvalidOperationException`); use
`FontManager::try_get_glyph_typeface` to handle that case.

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

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

### normalize

```rust
fn normalize(self: &Self) -> (Typeface, String)
```

Splits style, weight and stretch words (e.g. "Bold", "Italic") out of
the primary family name. Returns the typeface with the matched values
applied and the family name without the matched words.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `From<&Typeface>`
- `Clone`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`
- `Default`
- `Hash`
- `From<FontFamily>`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
