Skip to main content

text_typeset/shaping/
run.rs

1use std::ops::Range;
2
3use crate::types::FontFaceId;
4
5#[derive(Clone)]
6pub struct ShapedGlyph {
7    pub glyph_id: u16,
8    pub cluster: u32,
9    pub x_advance: f32,
10    pub y_advance: f32,
11    pub x_offset: f32,
12    pub y_offset: f32,
13    /// Font face for this specific glyph. May differ from the run's font_face_id
14    /// when glyph fallback replaced a .notdef with a glyph from another font.
15    pub font_face_id: FontFaceId,
16}
17
18#[derive(Clone)]
19pub struct ShapedRun {
20    pub font_face_id: FontFaceId,
21    pub size_px: f32,
22    pub glyphs: Vec<ShapedGlyph>,
23    pub advance_width: f32,
24    pub text_range: Range<usize>,
25    /// Decoration flags from the source fragment's TextFormat.
26    pub underline_style: crate::types::UnderlineStyle,
27    pub overline: bool,
28    pub strikeout: bool,
29    pub is_link: bool,
30    /// Text foreground color (RGBA). None means default (black).
31    pub foreground_color: Option<[f32; 4]>,
32    /// Underline color (RGBA). None means use foreground_color.
33    pub underline_color: Option<[f32; 4]>,
34    /// Text-level background highlight color (RGBA). None means transparent.
35    pub background_color: Option<[f32; 4]>,
36    /// Hyperlink destination URL.
37    pub anchor_href: Option<String>,
38    /// Tooltip text.
39    pub tooltip: Option<String>,
40    /// Vertical alignment (normal, superscript, subscript).
41    pub vertical_alignment: crate::types::VerticalAlignment,
42    /// If Some, this run represents an inline image placeholder.
43    pub image_name: Option<String>,
44    /// Image height in pixels (used for line height expansion).
45    pub image_height: f32,
46}