ailloli_ui_text/
glyph.rs

1//! Backend-neutral glyph placement produced by the text layout pipeline.
2
3/// One positioned glyph in logical layout space.
4///
5/// The matching font bytes remain owned by [`crate::TextSystem`]. Coordinates
6/// are logical pixels relative to the layout origin; they are not rounded to
7/// device pixels. `color` is absent for layouts that use one caller-supplied
8/// paint color and present for styled runs that carry their own color.
9///
10/// # Examples
11///
12/// ```
13/// use ailloli_ui_text::GlyphInstance;
14///
15/// let glyph = GlyphInstance {
16///     face_id: 7,
17///     font_index: 0,
18///     glyph_id: 42,
19///     px_size: 16,
20///     x: 12.5,
21///     y: 20.0,
22///     color: None,
23/// };
24/// assert_eq!(glyph.glyph_id, 42);
25/// assert_eq!(glyph.color, None);
26/// ```
27#[derive(Debug, Clone, Copy, PartialEq)]
28pub struct GlyphInstance {
29    /// Stable identifier of the selected font face within the Parley database.
30    pub face_id: u64,
31    /// Face index inside a font collection; zero for ordinary single-face fonts.
32    pub font_index: u32,
33    /// Font-specific glyph identifier used for rasterization.
34    pub glyph_id: u32,
35    /// Requested font size in logical pixels, rounded and clamped to at least one.
36    pub px_size: u16,
37    /// Horizontal glyph origin in logical pixels.
38    pub x: f32,
39    /// Vertical glyph origin in logical pixels.
40    pub y: f32,
41    /// Per-run linear-RGBA color, or `None` when paint supplies a uniform color.
42    pub color: Option<ailloli_ui_core::Color>,
43}