pub struct TextRun {
pub range: Range<usize>,
pub font: FontSpec,
pub color: Option<Color>,
pub background: Option<Color>,
pub underline: Underline,
pub strikethrough: bool,
pub link: Option<String>,
}Expand description
One styled span of a label’s text (docs/text-runs.md).
range is a byte range into the label’s text. Bytes, not chars: every backend that takes a
structured attributed string wants UTF-16 or byte offsets, str slicing is byte-based, and a
char count would have to be converted at every boundary. Ranges must be non-overlapping and
ascending; a gap between them is unstyled text, drawn with the label’s own font.
A run says only what differs. font is the whole descriptor rather than a delta because a
bold run inside a Body paragraph is FontSpec { style: Body, weight: Some(Bold), .. }. The
style has to travel with the weight or the run loses its semantic size.
Fields§
§range: Range<usize>§font: FontSpec§color: Option<Color>§background: Option<Color>A highlight painted behind the glyphs. Every native text editor carries this attribute (docs/texteditor.md), and search hits and review comments are the two things an app is asked for the moment it has styled text at all.
underline: UnderlineA line under the text.
strikethrough: boolA line through the text. Separate from FontSpec because it is a decoration, not a face:
no platform expresses it by picking a different font.
link: Option<String>Makes this run a link to the given target. Rendering it is Cap::TextRuns; making it
activatable is Cap::TextLinks, which is a smaller set (see the docs).
Implementations§
Source§impl TextRun
impl TextRun
Sourcepub fn font(range: Range<usize>, font: FontSpec) -> TextRun
pub fn font(range: Range<usize>, font: FontSpec) -> TextRun
A run that only changes the font, the common case for emphasis.
Trait Implementations§
impl StructuralPartialEq for TextRun
Auto Trait Implementations§
impl Freeze for TextRun
impl RefUnwindSafe for TextRun
impl Send for TextRun
impl Sync for TextRun
impl Unpin for TextRun
impl UnsafeUnpin for TextRun
impl UnwindSafe for TextRun
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more