Skip to main content

TextSpec

Struct TextSpec 

Source
pub struct TextSpec {
Show 18 fields pub content: String, pub size_px: f32, pub color: Color, pub alignment: Alignment, pub italic: bool, pub weight: f32, pub max_lines: Option<usize>, pub ellipsis: bool, pub font_family: Option<String>, pub line_height: f32, pub runs: Option<Vec<(usize, usize, Color)>>, pub underline: bool, pub strikethrough: bool, pub spans: Option<Vec<TextSpan>>, pub letter_spacing: f32, pub word_spacing: f32, pub no_wrap: bool, pub overflow_wrap: bool,
}
Expand description

Texto a pintar dentro de un nodo. Alineación por defecto Center (horizontal y vertical), apta para labels de botón. Para layouts tipo editor o párrafo, usar .text_aligned(...) con Alignment::Start.

Fields§

§content: String§size_px: f32§color: Color§alignment: Alignment§italic: bool

true = forzar variante italic en la fuente activa. Default false.

§weight: f32

Peso de fuente CSS: 400 = normal, 700 = bold. parley elige la variante más cercana de la familia activa (o la sintetiza). Se usa tanto al medir como al pintar, así medida y dibujo coinciden. Default 400.

§max_lines: Option<usize>

Límite de líneas (CSS -webkit-line-clamp / Flutter maxLines). None = sin límite (envuelve libre). Cuando el texto excede, se trunca: con Self::ellipsis la última línea termina en , sin él se corta seco. Afecta medida (taffy reserva el alto de N líneas) y pintado.

§ellipsis: bool

Si true y max_lines trunca, la última línea visible termina en . Sin efecto si max_lines es None. Default false.

§font_family: Option<String>

CSS-style font-family string (acepta lista con fallbacks). None = la fuente default de parley.

§line_height: f32

Múltiplo de interlínea (line-height / font-size). 1.2 es el default que usaban todos los callers; puriy lo sobreescribe con el valor computado de CSS. Se usa tanto al medir (para que taffy reserve el alto correcto) como al pintar, así medida y dibujo coinciden.

§runs: Option<Vec<(usize, usize, Color)>>

Colores por rango de bytes sobre content, para texto multicolor (syntax highlighting) en una sola pasada de shaping. None = color uniforme (color). Cuando es Some, el runtime usa Typesetter::layout_runs + draw_layout_runs, y color actúa como color por defecto de lo no cubierto por ningún run.

§underline: bool

Subrayado activo. El runtime pinta la línea bajo la línea base usando las métricas (underline_offset, underline_size) que parley deriva de la fuente — así un texto a 12pt y otro a 24pt tienen un subrayado proporcional sin que el caller calcule nada.

§strikethrough: bool

Tachado activo. Mismo régimen que Self::underline pero sobre el strikethrough metric — útil para listas to-do, items removidos en un diff, precios viejos.

§spans: Option<Vec<TextSpan>>

Spans inline mixtos (RichText): overrides de tamaño/peso/italic/familia/color/underline/strikethrough por rango de bytes (parley convention). None = texto uniforme (camino layout_clamped); Some([]) se trata como None. Cuando hay spans, el runtime usa Typesetter::layout_spans (Layout con max_width/wrap) + draw_layout_runs_xf; los campos del TextSpec son defaults a nivel bloque que cada span puede sobreescribir. Tier 2 final de PARIDAD-FLUTTER (Bloque 13).

§letter_spacing: f32

letter-spacing: px extra entre letras (CSS). 0 = normal. Afecta shaping y medida. Sólo el camino uniforme (layout_clamped); el camino de spans (RichText) lo ignora en v1.

§word_spacing: f32

word-spacing: px extra entre palabras (CSS). 0 = normal. Mismo régimen que Self::letter_spacing.

§no_wrap: bool

white-space: nowrap/pre: si true, el texto no envuelve — se shapea en una sola línea (break_all_lines(None)) sin importar el ancho disponible, y desborda la caja (lo recorta overflow: hidden si lo hay). Afecta medida (taffy reserva el ancho de la línea completa) y pintado. Default false (wrap libre, comportamiento previo). Sólo el camino uniforme (layout_clamped); el de spans (RichText) lo ignora en v1, igual que el clamp.

§overflow_wrap: bool

overflow-wrap: break-word/anywhere (o word-break: break-all): si true, una palabra más ancha que la caja se parte para que entre, en vez de desbordar. Afecta medida (taffy puede reservar menos ancho) y pintado. Default false (la palabra larga desborda — comportamiento previo). Sólo el camino uniforme (layout_clamped); el de spans (RichText) lo ignora en v1, igual que no_wrap/clamp.

Trait Implementations§

Source§

impl Clone for TextSpec

Source§

fn clone(&self) -> TextSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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,