densa_text/run.rs
1use densa_core::Color;
2
3use crate::{Font, GlyphId};
4
5/// A glyph placed by a text layout, relative to the layout's origin.
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct PositionedGlyph {
8 /// The glyph to draw.
9 pub id: GlyphId,
10 /// Pen position in pixels (may be fractional: drawn at the nearest subpixel bin).
11 pub x: f32,
12 /// Baseline in pixels, y down (rounded to a whole pixel when drawn).
13 pub y: f32,
14}
15
16/// Consecutive glyphs sharing one font, size and color: what a layout hands a renderer.
17///
18/// The common currency between text layout (which produces runs) and rendering (which draws
19/// them), so neither depends on the other.
20#[derive(Debug, Clone, Copy)]
21pub struct GlyphRun<'a> {
22 /// The face the glyph ids belong to.
23 pub font: &'a Font,
24 /// Size in pixels per em.
25 pub px: f32,
26 /// Text color.
27 pub color: Color,
28 /// The glyphs, in drawing order.
29 pub glyphs: &'a [PositionedGlyph],
30}