pub struct StyledText {
pub region: Rect,
pub scale: f32,
pub custom_padding: Option<(usize, usize)>,
pub gradient_region: Option<Rect>,
/* private fields */
}Expand description
A styled text. Construct one with StyledTextBuilder
Each text object may have different styling per span, each span is assigned a metadata
index which is propagated through cosmic_text attrs onto every DecodedGlyph::metadata
produced from this text. Use StyledText::style_at to resolve a metadata value back to its
TextStyle.
Note that styles not enabled in crate::Features are ignored at render time.
Fields§
§region: Rect§scale: f32§custom_padding: Option<(usize, usize)>§gradient_region: Option<Rect>Screen-space rectangle used to normalise gradient positions. Vertex positions are mapped
so that vertex at the the rect’s top-left corner is (0, 0) and its bottom-right corner is
(1, 1).
When None, StyledText::region is used instead. Set this explicitly when multiple
StyledText objects should share a single gradient that spans all of them.
Implementations§
Source§impl StyledText
impl StyledText
Sourcepub fn as_text(&self, id: u64) -> Text<'_>
pub fn as_text(&self, id: u64) -> Text<'_>
Borrow this styled text as a low-level Text for crate::MeshEncoder::encode.
id is supplied by the caller (e.g. crate::TextRenderer::prepare passes the
enumeration index) and surfaces on every produced DecodedGlyph::text_id.