# TextRun

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

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

```rust
trait TextRun: 'static
```

Represents a portion of a text line object.

Upstream `TextRun` is an abstract class whose subclasses are tested with
`is`/`as`. Here it is a trait: runs are handled as `Rc<dyn TextRun>` and
recovered with `dyn TextRun::downcast_ref` / `dyn TextRun::downcast_rc`,
or with the `as_*` hooks for the open base classes (`DrawableTextRun`,
`TextEndOfLine`).

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

## Members

- [`length`](#function-length)
- [`text`](#function-text)
- [`text_span`](#function-text_span)
- [`properties`](#function-properties)
- [`as_drawable`](#function-as_drawable)
- [`as_text_end_of_line`](#function-as_text_end_of_line)
- [`as_any`](#function-as_any)
- [`into_any_rc`](#function-into_any_rc)

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

### length

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

Gets the text source length (UTF-16 code units).

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

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

### text

```rust
fn text(self: &Self) -> ReadOnlyMemory<u16>
```

Gets the text run's text.

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

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

### text_span

```rust
fn text_span(self: &Self) -> &[u16]
```

Gets the text run's text as a slice. Runs with text override this
together with `TextRun::text`; hot paths read the slice.

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

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

### properties

```rust
fn properties(self: &Self) -> Option<&Rc<dyn TextRunProperties>>
```

A set of properties shared by every character in the run.

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

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

### as_drawable

```rust
fn as_drawable(self: &Self) -> Option<&dyn DrawableTextRun>
```

The run as a drawable run (C# `run is DrawableTextRun`).

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

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

### as_text_end_of_line

```rust
fn as_text_end_of_line(self: &Self) -> Option<&TextEndOfLine>
```

The run as an end of line marker (C# `run is TextEndOfLine`).

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

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

### as_any

```rust
fn as_any(self: &Self) -> &dyn Any
```

The run as `Any`, for downcasting to a concrete run type.

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

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

### into_any_rc

```rust
fn into_any_rc(self: Rc<Self>) -> Rc<dyn Any>
```

The run handle as `Any`, for downcasting to a concrete run handle.

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

## Trait implementations

- [`TextRun`](/docs/0.5.0/api/ferroui-base/media/text_formatting/trait-textrun/)

## Availability

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