pub struct Span<'a> {
pub text: &'a str,
pub color: Option<Color>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub underline_color: Option<Color>,
pub underline_style: UnderlineStyle,
pub strikethrough: bool,
pub bg: Option<Color>,
pub bg_radius: f32,
}Expand description
One styled run inside a rich-text paragraph. Spans are shaped and wrapped together as a single flow; plain data, so every frontend can build them.
Fields§
§text: &'a str§color: Option<Color>§bold: bool§italic: bool§underline: boolA line under the span, where the face puts its underline.
underline_color: Option<Color>The underline’s own colour; None is the span’s.
underline_style: UnderlineStyleThe underline’s shape.
strikethrough: boolA line through the span, where the face puts its strikeout.
bg: Option<Color>A background behind the span’s glyphs, one rect per line it spans, so it follows the span across a wrap the way a box cannot.
bg_radius: f32The background’s corner radius, logical px. Above zero, every background of the same colour and radius that meets another edge to edge on the line above or below — in this text or another — is one shape with it: its corners convex where a line reaches past its neighbour, concave where it falls short, round where nothing meets it. What a selection over lines looks like.
Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
pub fn new(text: &'a str) -> Self
pub fn color(self, c: Color) -> Self
pub fn bold(self) -> Self
pub fn italic(self) -> Self
pub fn underline(self) -> Self
Sourcepub fn underline_color(self, c: Color) -> Self
pub fn underline_color(self, c: Color) -> Self
An underline in its own colour; turns it on.
Sourcepub fn underline_style(self, s: UnderlineStyle) -> Self
pub fn underline_style(self, s: UnderlineStyle) -> Self
An underline of this shape; turns it on.
pub fn strikethrough(self) -> Self
pub fn bg(self, c: Color) -> Self
Sourcepub fn bg_radius(self, r: f32) -> Self
pub fn bg_radius(self, r: f32) -> Self
Rounds the background, joined with the ones it meets (see
Span::bg_radius).