# CharacterFormat

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/documents/struct-characterformat/

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

```rust
struct CharacterFormat
```

A character-format patch, also used to capture the assigned formatting of an
element. `None` leaves a property unchanged. For nullable properties,
`Some(None)` explicitly clears it. Snapshots copy mutable formatting collections.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L17)

## Members

- [`language`](#struct_field-language)
- [`font_family`](#struct_field-font_family)
- [`font_size`](#struct_field-font_size)
- [`font_style`](#struct_field-font_style)
- [`font_weight`](#struct_field-font_weight)
- [`font_stretch`](#struct_field-font_stretch)
- [`font_features`](#struct_field-font_features)
- [`typography`](#struct_field-typography)
- [`foreground`](#struct_field-foreground)
- [`background`](#struct_field-background)
- [`text_decorations`](#struct_field-text_decorations)
- [`baseline_alignment`](#struct_field-baseline_alignment)
- [`letter_spacing`](#struct_field-letter_spacing)
- [`from_element`](#function-from_element)
- [`effective`](#function-effective)
- [`overlay`](#function-overlay)
- [`validate`](#function-validate)
- [`try_apply_to`](#function-try_apply_to)
- [`language_tag`](#function-language_tag)
- [`set_language_tag`](#function-set_language_tag)

<a id="struct_field-language"></a>

### language

```rust
language: Option<ferroui_base::utilities::Locale>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L18)

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

### font_family

```rust
font_family: Option<ferroui_base::media::FontFamily>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L19)

<a id="struct_field-font_size"></a>

### font_size

```rust
font_size: Option<f64>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L20)

<a id="struct_field-font_style"></a>

### font_style

```rust
font_style: Option<ferroui_base::media::FontStyle>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L21)

<a id="struct_field-font_weight"></a>

### font_weight

```rust
font_weight: Option<ferroui_base::media::FontWeight>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L22)

<a id="struct_field-font_stretch"></a>

### font_stretch

```rust
font_stretch: Option<ferroui_base::media::FontStretch>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L23)

<a id="struct_field-font_features"></a>

### font_features

```rust
font_features: Option<Option<ferroui_base::media::FontFeatureCollection>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L24)

<a id="struct_field-typography"></a>

### typography

```rust
typography: super::TypographyFormat
```

Each assigned typography field is patched independently. Effective
formats contain all resolved values, including explicit defaults.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L27)

<a id="struct_field-foreground"></a>

### foreground

```rust
foreground: Option<Option<std::rc::Rc<dyn IBrush>>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L28)

<a id="struct_field-background"></a>

### background

```rust
background: Option<Option<std::rc::Rc<dyn IBrush>>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L29)

<a id="struct_field-text_decorations"></a>

### text_decorations

```rust
text_decorations: Option<Option<ferroui_base::media::TextDecorationCollection>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L30)

<a id="struct_field-baseline_alignment"></a>

### baseline_alignment

```rust
baseline_alignment: Option<ferroui_base::media::BaselineAlignment>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L31)

<a id="struct_field-letter_spacing"></a>

### letter_spacing

```rust
letter_spacing: Option<f64>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L32)

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

### from_element

```rust
fn from_element(element: &TextElement) -> Self
```

Captures assigned properties without flattening inherited span formatting.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L137)

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

### effective

```rust
fn effective(element: &TextElement) -> Self
```

Captures computed values, including formatting inherited through logical parents.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L164)

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

### overlay

```rust
fn overlay(self: &Self, patch: &Self) -> Self
```

Returns this format with every assigned field of `patch` replaced.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L188)

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

### validate

```rust
fn validate(self: &Self) -> Result<(), super::DocumentError>
```

Whether the assigned values are valid. A language is a locale, which is
always a valid XML language tag.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L213)

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

### try_apply_to

```rust
fn try_apply_to(self: &Self, element: &TextElement) -> Result<(), super::DocumentError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L227)

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

### language_tag

```rust
fn language_tag(self: &Self) -> Option<String>
```

The assigned native LanguageTag value: the BCP-47 tag of the locale, empty
for the invariant culture (the unknown locale `und`). None means that this
patch leaves language unchanged; mixed range values use TextFormatValue as
usual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L297)

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

### set_language_tag

```rust
fn set_language_tag(self: &mut Self, tag: &str) -> Result<(), super::DocumentError>
```

Assigns the language of a tag without modifying any other character
formatting: the empty tag is the invariant culture (the unknown locale
`und`), any other tag has to be a valid XML language tag and a BCP-47
language tag (the locale holds it with the case of its subtags
normalized). Validation completes before this patch changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/documents/character_format.rs#L306)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`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/)
- `ErasedDestructor`
- `IntoEither`
- `Default`
- `Debug`
- `Clone`
- `PartialEq`

## Availability

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