Skip to main content

Text

Struct Text 

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

A text label with newline handling, kerning, and optional character wrapping.

The family is independent of size and weight: Text::monospace sets the text in the code font on a fixed cell grid, Text::tabular_numbers gives proportional text digits of equal width. Both are separate from Text::wrap, which stays on by default; call wrap(false) for code and columns so lines are never broken, only clipped by the parent.

Implementations§

Source§

impl Text

Source

pub fn new(text: impl Into<String>) -> Self

Source

pub fn style(self, style: TextStyle) -> Self

Source

pub fn typography(self, role: TypographyRole) -> Self

Source

pub fn size(self, size: f32) -> Self

Source

pub fn weight(self, weight: FontWeight) -> Self

The font file weight for this text; overrides the style and the role.

Source

pub fn monospace(self) -> Self

Set the text in the monospace family (bundled JetBrains Mono by default). Overrides the style and the role; see Ui::monospace_metrics for the cell size.

Source

pub fn family(self, family: TextFamily) -> Self

The font family of this text; overrides the style and the role.

Source

pub fn tabular_numbers(self, tabular: bool) -> Self

Tabular figures: every digit has the width of the widest one, so numbers in a column line up. Uses the font’s OpenType tnum feature; a font without it (or the monospace family, which is already tabular) renders unchanged. Never fakes alignment by padding.

Source

pub fn tab_size(self, cells: u16) -> Self

Width of a tab character in cells (space advances), at least 1; default 8.

Source

pub fn muted(self) -> Self

Source

pub fn color(self, color: Color) -> Self

Source

pub fn wrap(self, wrap: bool) -> Self

Trait Implementations§

Source§

impl Widget for Text

Source§

fn ui(self, ui: &mut Ui<'_>) -> Response

Source§

fn tooltip(self, text: impl Into<String>) -> TooltipWidget<Self>
where Self: Sized,

Show a tooltip while the widget is hovered, in the same expression: ui.add(Button::new("Save").tooltip("Write the file")).
Source§

fn context_menu(self, items: &[ContextMenuItem]) -> ContextMenuWidget<'_, Self>
where Self: Sized,

Open a context menu on secondary click. The chosen item is reported by Response::menu_selected on the pass it is picked.
Source§

fn accessible_label(self, label: impl Into<String>) -> Accessible<Self>
where Self: Sized,

The name a screen reader speaks for this widget, replacing the one it derives from its visible text. Required for controls without text: an icon button, a bare switch, a slider without a caption.
Source§

fn accessible_description( self, description: impl Into<String>, ) -> Accessible<Self>
where Self: Sized,

Extra detail a screen reader speaks after the name: a hint or the reason for an error.
Source§

fn accessible_role(self, role: AccessRole) -> Accessible<Self>
where Self: Sized,

Present this widget to assistive technology as role. A custom widget that does not describe itself becomes a node of this role with the response’s bounds.
Source§

fn accessibility_hidden(self) -> Accessible<Self>
where Self: Sized,

Leave this widget and everything in it out of the accessibility tree: decoration that says nothing a screen reader user needs.

Auto Trait Implementations§

§

impl Freeze for Text

§

impl RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl UnsafeUnpin for Text

§

impl UnwindSafe for Text

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more