pub struct TextPrimitiveNode {
pub node_id: NodeId,
pub rect: Rect,
pub text: Rc<AnnotatedString>,
pub render_text: Arc<RenderString>,
pub layout: TextLayout,
pub text_style: Arc<TextStyle>,
pub font_size: f32,
pub overflow: TextOverflow,
pub clip: Option<Rect>,
pub paint: TextPaintCache,
}Expand description
A run of text to draw, with the layout facts that a renderer needs.
Fields§
§node_id: NodeIdLayout node that owns the text.
rect: RectBox of the laid-out text in logical pixels, after alignment and panning.
text: Rc<AnnotatedString>Shared so the renderer can hand the same allocation to every draw it emits for this node instead of deep-copying the string once per emit.
render_text: Arc<RenderString>text as the renderer’s draws carry it across threads, shared with
the prepared layout it came from so no frame converts it again.
layout: TextLayoutThe lines and glyphs the text draws, from its top left corner at
rect’s.
text_style: Arc<TextStyle>Shared so every frame’s draws of this text hand over the same style instead of copying it.
font_size: f32Resolved font size in logical pixels.
overflow: TextOverflowHow the text was laid out to handle text that does not fit.
clip: Option<Rect>Rectangle that cuts the glyphs: the node’s box when the layout overflows it and overflow
is not visible, or when the text pans; None otherwise, as Compose cuts a text.
paint: TextPaintCacheWhat a renderer reads of text_style and text’s spans to draw the
glyphs, so that drawing a plain text does not load the style.
Implementations§
Source§impl TextPrimitiveNode
impl TextPrimitiveNode
Sourcepub fn draw_bounds(&self) -> Option<Rect>
pub fn draw_bounds(&self) -> Option<Rect>
Conservative bounds for the emitted glyphs and paint: the clip, or
the layout rectangle and wherever the ink of a glyph, a stroke’s
included, reaches past it. Returns None when an unclipped layout or
style can draw beyond both: a visible overflow, a shadow of the style
or a span, or a baseline shift.