ass_core/analysis/styles/resolved_style/mod.rs
1//! Resolved style representation with computed values and metrics
2//!
3//! Provides the `ResolvedStyle` struct containing fully computed style properties
4//! after applying inheritance, overrides, and default fallbacks. Includes
5//! performance analysis and rendering complexity assessment.
6//!
7//! # Features
8//!
9//! - Zero-copy style name references to original definitions
10//! - Computed RGBA color values for efficient rendering
11//! - Performance complexity scoring (0-100 scale)
12//! - Font and layout property validation
13//! - Memory-efficient representation via packed fields
14//!
15//! # Performance
16//!
17//! - Target: <0.1ms per style resolution
18//! - Memory: ~200 bytes per resolved style
19//! - Zero allocations for style name references
20
21use alloc::string::String;
22
23mod accessors;
24mod from_style;
25mod inheritance;
26mod parsing;
27mod scaling;
28
29#[cfg(test)]
30mod formatting_tests;
31#[cfg(test)]
32mod parse_tests;
33#[cfg(test)]
34mod resolution_tests;
35#[cfg(test)]
36mod scaling_tests;
37#[cfg(test)]
38mod test_support;
39
40bitflags::bitflags! {
41 /// Text formatting options for resolved styles
42 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
43 pub struct TextFormatting: u8 {
44 /// Bold text formatting
45 const BOLD = 1 << 0;
46 /// Italic text formatting
47 const ITALIC = 1 << 1;
48 /// Underline text formatting
49 const UNDERLINE = 1 << 2;
50 /// Strike-through text formatting
51 const STRIKE_OUT = 1 << 3;
52 }
53}
54
55/// Fully resolved style with computed values and performance metrics
56///
57/// Contains effective style values after applying inheritance, overrides,
58/// and defaults. Optimized for rendering with pre-computed color values
59/// and complexity scoring for performance assessment.
60#[derive(Debug, Clone, PartialEq)]
61pub struct ResolvedStyle<'a> {
62 /// Original style name (zero-copy reference)
63 pub name: &'a str,
64 /// Resolved font family name
65 font_name: String,
66 /// Font size in points
67 font_size: f32,
68 /// Primary text color (RGBA)
69 primary_color: [u8; 4],
70 /// Secondary text color (RGBA)
71 secondary_color: [u8; 4],
72 /// Outline color (RGBA)
73 outline_color: [u8; 4],
74 /// Background color (RGBA)
75 back_color: [u8; 4],
76 /// Text formatting flags
77 formatting: TextFormatting,
78 /// Scaling factors (percentage)
79 /// Horizontal scaling factor
80 scale_x: f32,
81 /// Vertical scaling factor
82 scale_y: f32,
83 /// Character spacing
84 spacing: f32,
85 /// Text rotation angle
86 angle: f32,
87 /// Border style (`0=outline+drop_shadow`, `1=opaque_box`)
88 border_style: u8,
89 /// Outline thickness
90 outline: f32,
91 /// Shadow distance
92 shadow: f32,
93 /// Text alignment (1-9, numpad layout)
94 alignment: u8,
95 /// Margins in pixels
96 /// Left margin in pixels
97 margin_l: u16,
98 /// Right margin in pixels
99 margin_r: u16,
100 /// Top margin in pixels
101 margin_t: u16,
102 /// Bottom margin in pixels
103 margin_b: u16,
104 /// Text encoding
105 encoding: u8,
106 /// Rendering complexity score (0-100)
107 complexity_score: u8,
108}