1
//! Small geometry types used by the layout solver and text shaping pipeline.
2
//!
3
//! Default font / text constants live in [`azul_css::defaults`].
4

            
5
use crate::geom::{LogicalPosition, LogicalSize};
6

            
7
/// Resolved top/right/bottom/left offsets in logical pixels (used for
8
/// margins, padding, and borders after CSS resolution).
9
#[derive(Debug, Default, Copy, Clone, PartialEq, PartialOrd)]
10
#[repr(C)]
11
pub struct ResolvedOffsets {
12
    pub top: f32,
13
    pub left: f32,
14
    pub right: f32,
15
    pub bottom: f32,
16
}
17

            
18
impl ResolvedOffsets {
19
    #[must_use]
20
3
    pub const fn zero() -> Self {
21
3
        Self {
22
3
            top: 0.0,
23
3
            left: 0.0,
24
3
            right: 0.0,
25
3
            bottom: 0.0,
26
3
        }
27
3
    }
28
    #[must_use]
29
16
    pub fn total_vertical(&self) -> f32 {
30
16
        self.top + self.bottom
31
16
    }
32
    #[must_use]
33
15
    pub fn total_horizontal(&self) -> f32 {
34
15
        self.left + self.right
35
15
    }
36
}
37

            
38
/// Index into a font's glyph table.
39
type GlyphIndex = u32;
40

            
41
/// A single positioned glyph with its index, screen position, and size.
42
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd)]
43
pub struct GlyphInstance {
44
    pub index: GlyphIndex,
45
    pub point: LogicalPosition,
46
    pub size: LogicalSize,
47
}
48

            
49
impl GlyphInstance {
50
13
    pub fn scale_for_dpi(&mut self, scale_factor: f32) {
51
13
        self.point.scale_for_dpi(scale_factor);
52
13
        self.size.scale_for_dpi(scale_factor);
53
13
    }
54
}
55

            
56
#[cfg(test)]
57
#[path = "ui_solver_test.rs"]
58
mod ui_solver_test;