pub struct TextElement {Show 14 fields
pub font: FontSpec,
pub color: Option<ThemeColor>,
pub size_pt: Option<Length>,
pub align: Option<HAlign>,
pub valign: Option<VAlign>,
pub angle: Option<Rotation>,
pub lineheight: Option<Length>,
pub letter_spacing: Option<Length>,
pub underline: Option<bool>,
pub strikethrough: Option<bool>,
pub margin: Option<Margin>,
pub text_stroke: Option<ThemeColor>,
pub text_linewidth_pt: Option<Length>,
pub markdown: Option<bool>,
}Expand description
Text styling — font selection, colour, size, alignment, rotation, line height, margin.
Every field is Option<...> so an override can set just the
fields it cares about, with the rest cascading through the
parent chain. After cascading, callers fall through to
text_concrete_defaults for any remaining Nones.
Fields§
§font: FontSpecFont specification. Each FontSpec field cascades
independently — a child can override weight while inheriting
family.
color: Option<ThemeColor>Ink colour. Resolved against the theme’s palette at draw time.
size_pt: Option<Length>Font size. Resolves against the inherited parent’s resolved
size — Rel(1.5) = 1.5× the parent.
align: Option<HAlign>Horizontal alignment within the slot.
valign: Option<VAlign>Vertical alignment within the slot.
angle: Option<Rotation>Rotation — absolute degrees, or Along / Across to follow
the surface’s baseline direction.
lineheight: Option<Length>Line height — typically Rel(1.2) (120% of the resolved size).
letter_spacing: Option<Length>Letter spacing (tracking). Length::Abs(pt) is absolute pt
between glyph pairs; Length::Rel(m) is m × resolved_size_pt.
Abs(0.0) (the default) is the natural font advance.
underline: Option<bool>Underline the text. Position and thickness are taken from the font’s reported metrics.
strikethrough: Option<bool>Strike through the text. Position and thickness are taken from the font’s reported metrics.
margin: Option<Margin>Margin around the text block, each side independent.
text_stroke: Option<ThemeColor>Per-glyph outline color. None renders no outline — the one
field text_concrete_defaults leaves unset, since a concrete
value here would halo every string in the figure. A child layer
therefore cannot clear an outline a parent set by writing
None; set text_linewidth_pt to Abs(0.0) instead.
Mirrors the "text_stroke" channel on the text geoms.
text_linewidth_pt: Option<Length>Outline thickness. Resolves against DEFAULT_LINEWIDTH_PT,
the parent every other linewidth in the theme resolves against,
so Rel(2.0) is twice the standard hairline rather than a
multiple of the font size. Has no effect unless text_stroke
resolves to a color.
The stroke centres on the glyph contour and does not grow the
text’s measured box, matching the text geoms — a deliberately
heavy outline needs clearance from margin, which is measured.
markdown: Option<bool>Interpret the slot’s string as marquee-flavoured markdown and
shape it through the rich-text pipeline
(crate::text::rich::RichTextRun). Off by default so every
existing chrome label renders unchanged.
When on, the slot’s crate::plot::theme::Theme::rich_text
style sheet drives the markdown styling; the TextElement’s
resolved font / colour / size / letter-spacing feed into the
rich run’s base style so plain-text fragments still inherit
the slot’s ambient look.
Text-outline (text_stroke / text_linewidth_pt) is not
applied on markdown slots — the rich pipeline doesn’t expose
a glyph-outline surface. Chrome renderers fall back to plain
text when an outline is needed on the same slot.
Implementations§
Source§impl TextElement
impl TextElement
Sourcepub fn cascade(&self, parent: &Self) -> Self
pub fn cascade(&self, parent: &Self) -> Self
Merge self over parent: per-field, self’s Some wins;
None falls through to parent’s value. font cascades
through FontSpec::cascade (each FontSpec field merges
independently; feature / variation lists merge by tag).
Trait Implementations§
Source§impl Clone for TextElement
impl Clone for TextElement
Source§fn clone(&self) -> TextElement
fn clone(&self) -> TextElement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TextElement
impl Debug for TextElement
Source§impl Default for TextElement
impl Default for TextElement
Source§fn default() -> TextElement
fn default() -> TextElement
Source§impl PartialEq for TextElement
impl PartialEq for TextElement
impl StructuralPartialEq for TextElement
Auto Trait Implementations§
impl Freeze for TextElement
impl RefUnwindSafe for TextElement
impl Send for TextElement
impl Sync for TextElement
impl Unpin for TextElement
impl UnsafeUnpin for TextElement
impl UnwindSafe for TextElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Brush for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.