Skip to main content

TextScope

Struct TextScope 

Source
pub struct TextScope { /* private fields */ }
Expand description

A Text and its builder.

Implementations§

Source§

impl TextScope

Source

pub fn spans(self, spans: TextSpans) -> Self

Runs of different treatment inside the text: a bold phrase, a link, some code.

Source

pub fn type_role(self, role: TypeRole) -> Self

Source

pub fn font_size(self, sp: f32) -> Self

Source

pub fn font_weight(self, weight: u16) -> Self

Source

pub fn line_height(self, sp: f32) -> Self

Explicit line height in sp, or NaN (normal) to use the font’s own metrics. An unset line height (0 or never calling this) falls back to the type role’s line height.

Source

pub fn letter_spacing(self, sp: f32) -> Self

Extra space between letters, in sp. 0 draws no extra spacing; NaN, like never calling this, takes the type role’s spacing.

Source

pub fn color(self, paint: Paint) -> Self

Source

pub fn text_align(self, align: TextAlign) -> Self

Source

pub fn max_lines(self, lines: u32) -> Self

Source

pub fn overflow(self, overflow: TextOverflow) -> Self

Source

pub fn font(self, font: FontRefs) -> Self

The fonts to try, in order. Only text with TypeRole::None takes its own fonts; text with a role is set in the theme’s font for that role.

Source

pub fn font_feature_settings(self, features: &[FontFeature]) -> Self

OpenType features of the font the text is set in, such as FontFeature::TABULAR_NUMS for digits of one width. Compose’s TextStyle.fontFeatureSettings, CSS’s font-feature-settings.

Taken with or without a type role: a feature picks one of the forms the font already has and does not change the font. A tag given twice takes the later value, an empty list is no features, and at most MAX_FONT_FEATURES (16) are taken. A font without the feature draws as it would have.

Source

pub fn word_break(self, word_break: WordBreak) -> Self

Where a line may break inside a word. CSS word-break.

Source

pub fn overflow_wrap(self, overflow_wrap: OverflowWrap) -> Self

Whether a token too long for its line, such as a path or a URL, may break inside itself. CSS overflow-wrap. With Anywhere such a token breaks between its letters even under WordBreak::KeepAll; tokens that fit keep the breaking rule they had.

Source§

impl TextScope

Source

pub fn modifier(self, modifier: Modifier) -> Self

What sits around it. Compose’s modifier parameter.

Source§

impl TextScope

Source

pub fn on_motion_finished( self, handler: impl FnMut(MotionFinished) + 'static, ) -> Self

Runs once when this node’s size motion comes to rest, with the size it settled at in dp. The node needs Modifier::motion for its size to move; without it nothing is reported. A run interrupted by a newer size is not reported, only the one that settles, and under reduced motion it arrives in the frame the size changes in.

Source§

impl TextScope

Source

pub fn on_pointer( self, kinds: PointerKinds, handler: impl FnMut(PointerEvent) + 'static, ) -> Self

Subscribes the node to the kinds of pointer input in kinds. The handler runs on the same call as the input; calling consume on the event keeps it from the nearest subscribed ancestor and from the Renderer’s own handling.

A node that never calls this has no pointer input at all, and costs nothing.

Trait Implementations§

Source§

impl Drop for TextScope

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.