Skip to main content

text_typeset/layout/
line.rs

1use std::ops::Range;
2
3use crate::shaping::run::ShapedRun;
4
5pub struct LayoutLine {
6    pub runs: Vec<PositionedRun>,
7    /// Baseline y relative to block top (set by block layout).
8    pub y: f32,
9    pub ascent: f32,
10    pub descent: f32,
11    pub leading: f32,
12    /// Total line height: ascent + descent + leading.
13    pub line_height: f32,
14    /// Actual content width (sum of run advances).
15    pub width: f32,
16    /// Character range in the block's text.
17    pub char_range: Range<usize>,
18}
19
20pub struct PositionedRun {
21    pub shaped_run: ShapedRun,
22    /// X offset from the left edge of the content area.
23    pub x: f32,
24    /// Decoration flags for this run.
25    pub decorations: RunDecorations,
26}
27
28/// Text decoration flags carried from the source TextFormat.
29#[derive(Clone, Copy, Debug, Default)]
30pub struct RunDecorations {
31    pub underline: bool,
32    pub overline: bool,
33    pub strikeout: bool,
34    pub is_link: bool,
35}