pub trait FormattableText: Debug {
fn as_str(&self) -> &str;
fn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken>ⓘNotable traits for OwningVecIter<T>impl<T> Iterator for OwningVecIter<T>where
T: Clone, type Item = T;;
fn effect_tokens(&self) -> &[Effect<()>];
fn str_len(&self) -> usize { ... }
}Expand description
Text, optionally with formatting data
Any F: FormattableText automatically support FormattableTextDyn.
Implement either this or FormattableTextDyn, not both.
This trait can only be written as intended using Generic Associated Types
(gat, unstable nightly feature), thus font_tokens has a different
signature with/without feature gat and the associated type
FontTokenIter is only present with feature gat.
Required Methods
sourcefn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken>ⓘNotable traits for OwningVecIter<T>impl<T> Iterator for OwningVecIter<T>where
T: Clone, type Item = T;
fn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken>ⓘNotable traits for OwningVecIter<T>impl<T> Iterator for OwningVecIter<T>where
T: Clone, type Item = T;
T: Clone, type Item = T;
Construct an iterator over formatting items
It is expected that FontToken::start of yielded items is strictly
increasing; if not, formatting may not be applied correctly.
The dpem parameter is font size as in crate::Environment.
For plain text this iterator will be empty.
sourcefn effect_tokens(&self) -> &[Effect<()>]
fn effect_tokens(&self) -> &[Effect<()>]
Get the sequence of effect tokens
This method has some limitations: (1) it may only return a reference to
an existing sequence, (2) effect tokens cannot be generated dependent
on input state, and (3) it does not incorporate color information. For
most uses it should still be sufficient, but for other cases it may be
preferable not to use this method (use a dummy implementation returning
&[] and use inherent methods on the text object via Text::text).
Provided Methods
Length of text
Default implementation uses FormattableText::as_str.
Implementations on Foreign Types
sourceimpl FormattableText for String
impl FormattableText for String
fn as_str(&self) -> &str
fn font_tokens(&self, f32) -> OwningVecIter<FontToken>ⓘNotable traits for OwningVecIter<T>impl<T> Iterator for OwningVecIter<T>where
T: Clone, type Item = T;
T: Clone, type Item = T;
fn effect_tokens(&self) -> &[Effect<()>]
sourceimpl<'t> FormattableText for &'t str
impl<'t> FormattableText for &'t str
fn as_str(&self) -> &str
fn font_tokens(&self, f32) -> OwningVecIter<FontToken>ⓘNotable traits for OwningVecIter<T>impl<T> Iterator for OwningVecIter<T>where
T: Clone, type Item = T;
T: Clone, type Item = T;