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 /// Resolved font weight (CSS 100–900). Propagated to the glyph
23 /// rasterizer so variable-font `wght` axis is set correctly and
24 /// the glyph cache key distinguishes different weights.
25 pub weight: u16,
26 pub glyphs: Vec<ShapedGlyph>,
27 pub advance_width: f32,
28 pub text_range: Range<usize>,
29 /// Decoration flags from the source fragment's TextFormat.
30 pub underline_style: crate::types::UnderlineStyle,
31 pub overline: bool,
32 pub strikeout: bool,
33 pub is_link: bool,
34 /// Text foreground color (RGBA). None means default (black).
35 pub foreground_color: Option<[f32; 4]>,
36 /// Underline color (RGBA). None means use foreground_color.
37 pub underline_color: Option<[f32; 4]>,
38 /// Text-level background highlight color (RGBA). None means transparent.
39 pub background_color: Option<[f32; 4]>,
40 /// Hyperlink destination URL.
41 pub anchor_href: Option<String>,
42 /// Tooltip text.
43 pub tooltip: Option<String>,
44 /// Vertical alignment (normal, superscript, subscript).
45 pub vertical_alignment: crate::types::VerticalAlignment,
46 /// If Some, this run represents an inline image placeholder.
47 pub image_name: Option<String>,
48 /// Image height in pixels (used for line height expansion).
49 pub image_height: f32,
50}