# TextShaper

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

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

```rust
struct TextShaper
```

A class that is responsible for text shaping.

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

## Members

- [`current`](#function-current)
- [`shape_text`](#function-shape_text)
- [`shape_str`](#function-shape_str)
- [`shape_edited_text`](#function-shape_edited_text)

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

### current

```rust
fn current() -> Rc<TextShaper>
```

Gets the current text shaper.

Panics when no text shaper backend is registered.

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

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

### shape_text

```rust
fn shape_text(self: &Self, text: &ReadOnlyMemory<u16>, options: &TextShaperOptions) -> Rc<ShapedBuffer>
```

Shapes UTF-16 text.

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

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

### shape_str

```rust
fn shape_str(self: &Self, text: &str, options: &TextShaperOptions) -> Rc<ShapedBuffer>
```

Shapes a string.

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

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

### shape_edited_text

```rust
fn shape_edited_text(self: &Self, previous: &ShapedBuffer, text: &ReadOnlyMemory<u16>, options: &TextShaperOptions) -> Option<Rc<ShapedBuffer>>
```

Shapes `text`, an edit of the text `previous` is the shaping of (with the same options and
its concatenation flags, `TextShaperOptions::with_concat_flags`): the glyphs of `previous`
the edit leaves as they were are kept and only the text around the change is shaped again.
The result is the shaping of the whole of `text` with these options, with its own
concatenation flags for the next edit. `None` when nothing of `previous` can be kept (a
right-to-left text, a text that is a range of a longer one, a shaping without flags, a
change at the start of the text): the caller shapes `text` whole.

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

## 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`

## Availability

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