pub struct Text { /* private fields */ }Expand description
Authored display text with optional complete appearance and layout instructions.
Plain strings carry no local instructions. Content validation happens at the receiving constructor or preflight, without rewriting the source. Clones share immutable source bytes and retain complete local instructions.
use lichtung_plot::{NumericValues, DataAreaCorner, PlotTextAnnotation, Plot, Text, TextAlignment, TextLayout, TextPanel, Theme};
let style = Theme::publication().typography().get_composition()
.get_text_panel_title().clone().font_size(24.0)?;
let title = Text::new("Study\ncontext").style(style).alignment(TextAlignment::End);
let note = PlotTextAnnotation::new(DataAreaCorner::TopLeft, title.clone())?;
let plot = Plot::scatter(NumericValues::new("x", [0.0, 1.0]),
NumericValues::new("y", [1.0, 0.0]))
.title(title.clone()).title("Updated heading")
.caption(Text::new("Centered caption").alignment(TextAlignment::Center));
let panel = TextPanel::new(title, Text::new("Independent body")
.layout(TextLayout::default().alignment(TextAlignment::Start)))?;
assert_eq!(panel.title(), "Study\ncontext");
assert_eq!(note.text(), panel.title());Implementations§
Source§impl Text
impl Text
Sourcepub fn clear_style(self) -> Text
pub fn clear_style(self) -> Text
Remove local appearance without changing content or layout. The receiving owner’s Theme role supplies appearance when this value is used.
Sourcepub fn layout(self, layout: TextLayout) -> Text
pub fn layout(self, layout: TextLayout) -> Text
Supply a whole layout request, including an explicit default reset.
Sourcepub fn clear_layout(self) -> Text
pub fn clear_layout(self) -> Text
Remove the local layout request, rather than attach a present default. Passing this value to an existing slot still follows omission/preserve rules.
Sourcepub const fn get_layout(&self) -> Option<&TextLayout>
pub const fn get_layout(&self) -> Option<&TextLayout>
Distinguish an omitted layout from a present request.
Sourcepub fn alignment(self, alignment: TextAlignment) -> Text
pub fn alignment(self, alignment: TextAlignment) -> Text
Edit alignment within this text’s one layout request.
Trait Implementations§
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Forget for Text
impl Freeze for Text
impl Move 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.