core::text

Structs

Text

Renders and styles text through the target's native text system.

A constrained width with an omitted height allows native measurement to determine the height of wrapped content. Selection, editing, font loading, and accessibility behavior depend on the target's native implementation; test the intended interaction on each shipping target.

Properties

editable

Type: Property<bool>

Whether the text can be edited by the user.

selectable

Type: Property<bool>

Requests selectable text. On the current iOS/iPadOS path, non-editable text uses the interactive selection view only when clip is enabled.

clip

Type: Property<bool>

Whether text overflow is clipped to the node bounds.

text

Type: Property<String>

Text content to display.

style

Type: Property<TextStyle>

Text styling.

markdown

Type: Property<bool>

Whether text should be interpreted as Markdown.

wrap

Type: Property<bool>

Whether long text lines should wrap inside the node bounds.


TextStyle

Struct describing platform-agnostic text display properties. Interpolation eases font size and fill; font selection, underline, and alignment switch to the destination immediately. Glyphs do not morph.

Properties

font

Type: Property<Font>

Font family/source/style/weight configuration.

font_size

Type: Property<Size>

Font size, in pixels.

fill

Type: Property<Paint>

Text color. Native text patches reduce gradient fills to their first stop's color; use a solid fill for predictable text color.

underline

Type: Property<bool>

Whether text should be underlined.

align_multiline

Type: Property<TextAlignHorizontal>

Alignment for multiline text layout.

align_vertical

Type: Property<TextAlignVertical>

Vertical text alignment within its bounds.

align_horizontal

Type: Property<TextAlignHorizontal>

Horizontal text alignment within its bounds.

Enums

Font

Describes a font available to native text renderers.

Pax templates may use either the explicit [Font::Web] constructor or a contextual shorthand. A string names a locally available family with an empty source URL and normal style and weight:

font: "Times New Roman"

Named object fields describe font sources and optional modifiers. Omitted fields retain their defaults. Supplying family without url selects a locally available family, matching the string shorthand. weight accepts either [FontWeight] or its CSS numeric equivalent from 100 through 900:

font: {
    family: "Inter"
    url: "https://example.com/Inter-Italic.ttf"
    style: FontStyle::Italic
    weight: 700
}

Nonempty URLs identify font files, except that Google Fonts URLs containing fonts.googleapis.com/css receive special stylesheet handling. Relative asset URLs work on web. Apple chassis register TTF/OTF files from the project's assets/ directory at startup; select their actual family name with an empty URL, or use that family with the web asset URL in a shared declaration. The native Web-font loader itself does not resolve relative URLs into bundle resources. Browser-only aliases do not name the registered Apple family.

Font shorthand has no positional ("magic index") fields: named keys are canonical, and positional list/tuple forms are not accepted. Use the explicit [Font::Web] constructor as verbose longhand when needed.

Variants

Web(String, String, FontStyle, FontWeight)

Font described by family name, source URL, style, and weight.


FontStyle

Describes available font styles.

Variants

Normal
Italic
Oblique

FontWeight

Describes available font weights.

Variants

Thin
ExtraLight
Light
Normal
Medium
SemiBold
Bold
ExtraBold
Black

Implementations

decrease
pub fn decrease(weight: FontWeight) -> FontWeight

Returns the next lighter named font weight.

increase
pub fn increase(weight: FontWeight) -> FontWeight

Returns the next heavier named font weight.


TextAlignHorizontal

Describes available horizontal text alignments.

Variants

Left
Center

TextAlignVertical

Describes available vertical text alignments.

Variants

Top
Center
Bottom