Skip to main content

euv_core/font/system/
struct.rs

1use super::*;
2
3/// Metadata describing the active native or deterministic font rasterization provider.
4#[derive(Clone, Debug, Eq, Getter, New, PartialEq)]
5pub struct SystemFontInfo {
6    /// Active font backend discriminant.
7    #[get(type(copy))]
8    pub(crate) backend: FontRenderBackend,
9    /// Resolved human-readable system font family name.
10    pub(crate) family_name: String,
11    /// Whether full Unicode / CJK glyph shaping is supported.
12    #[get(type(copy))]
13    pub(crate) supports_unicode: bool,
14    /// Whether smooth subpixel/alpha anti-aliasing is enabled.
15    #[get(type(copy))]
16    pub(crate) supports_antialiasing: bool,
17}
18
19/// Cross-platform native system font provider backed by direct OS font APIs.
20#[derive(Clone, Debug, Getter)]
21pub struct NativeSystemFont {
22    /// Probed system font capability descriptor.
23    pub(crate) info: SystemFontInfo,
24    /// When `true`, bypasses OS font engines for bit-identical deterministic output.
25    #[get(type(copy))]
26    pub(crate) deterministic_only: bool,
27}
28
29/// Shelf-packed alpha8/RGBA8 glyph texture atlas ready for GPU texture upload.
30#[derive(Clone, Debug, Getter, New)]
31pub struct PackedGlyphAtlas {
32    /// Texture width in pixels.
33    #[get(type(copy))]
34    pub(crate) width: u32,
35    /// Texture height in pixels.
36    #[get(type(copy))]
37    pub(crate) height: u32,
38    /// Packed RGBA8 pixel data (white RGB with glyph alpha coverage).
39    pub(crate) pixels: Vec<u8>,
40    /// Atlas UV rectangles `(x, y, w, h)` per cached `GlyphKey`.
41    pub(crate) regions: HashMap<GlyphKey, (u32, u32, u32, u32)>,
42    /// Revision number matching the source `GlyphAtlas`.
43    #[get(type(copy))]
44    pub(crate) revision: u64,
45}
46
47#[cfg(any(target_os = "macos", target_os = "ios"))]
48#[repr(C)]
49#[derive(Clone, Copy)]
50pub(crate) struct CtRange {
51    pub(crate) location: isize,
52    pub(crate) length: isize,
53}
54
55#[cfg(any(target_os = "macos", target_os = "ios"))]
56#[repr(C)]
57#[derive(Clone, Copy)]
58pub(crate) struct CtPoint {
59    pub(crate) x: f64,
60    pub(crate) y: f64,
61}
62
63#[cfg(any(target_os = "macos", target_os = "ios"))]
64#[repr(C)]
65#[derive(Clone, Copy)]
66pub(crate) struct CtSize {
67    pub(crate) width: f64,
68    pub(crate) height: f64,
69}
70
71#[cfg(target_os = "windows")]
72#[repr(C)]
73#[derive(Clone, Copy, Default)]
74pub(crate) struct WinFixed {
75    pub(crate) fract: u16,
76    pub(crate) value: i16,
77}
78
79#[cfg(target_os = "windows")]
80#[repr(C)]
81#[derive(Clone, Copy, Default)]
82pub(crate) struct WinMat2 {
83    pub(crate) em11: WinFixed,
84    pub(crate) em12: WinFixed,
85    pub(crate) em21: WinFixed,
86    pub(crate) em22: WinFixed,
87}
88
89#[cfg(target_os = "windows")]
90#[repr(C)]
91#[derive(Clone, Copy, Default)]
92pub(crate) struct WinGlyphMetrics {
93    pub(crate) black_box_x: u32,
94    pub(crate) black_box_y: u32,
95    pub(crate) glyph_origin_x: i32,
96    pub(crate) glyph_origin_y: i32,
97    pub(crate) cell_inc_x: i16,
98    pub(crate) cell_inc_y: i16,
99}
100
101#[cfg(target_os = "windows")]
102#[repr(C)]
103#[derive(Clone, Copy, Default)]
104pub(crate) struct WinTextMetricW {
105    pub(crate) tm_height: i32,
106    pub(crate) tm_ascent: i32,
107    pub(crate) tm_descent: i32,
108    pub(crate) tm_internal_leading: i32,
109    pub(crate) tm_external_leading: i32,
110    pub(crate) tm_ave_char_width: i32,
111    pub(crate) tm_max_char_width: i32,
112    pub(crate) tm_weight: i32,
113    pub(crate) tm_overhang: i32,
114    pub(crate) tm_digitized_aspect_x: i32,
115    pub(crate) tm_digitized_aspect_y: i32,
116    pub(crate) tm_first_char: u16,
117    pub(crate) tm_last_char: u16,
118    pub(crate) tm_default_char: u16,
119    pub(crate) tm_break_char: u16,
120    pub(crate) tm_italic: u8,
121    pub(crate) tm_underlined: u8,
122    pub(crate) tm_struck_out: u8,
123    pub(crate) tm_pitch_and_family: u8,
124    pub(crate) tm_char_set: u8,
125}
126
127#[cfg(any(target_os = "linux", target_os = "android"))]
128#[repr(C)]
129#[derive(Clone, Copy)]
130pub(crate) struct FtBitmap {
131    pub(crate) rows: u32,
132    pub(crate) width: u32,
133    pub(crate) pitch: i32,
134    pub(crate) buffer: *const u8,
135    pub(crate) num_grays: u16,
136    pub(crate) pixel_mode: u8,
137    pub(crate) palette_mode: u8,
138    pub(crate) palette: *mut c_void,
139}
140
141#[cfg(any(target_os = "linux", target_os = "android"))]
142#[repr(C)]
143#[derive(Clone, Copy)]
144pub(crate) struct FtVector {
145    pub(crate) x: isize,
146    pub(crate) y: isize,
147}
148
149#[cfg(any(target_os = "linux", target_os = "android"))]
150#[repr(C)]
151#[derive(Clone, Copy)]
152pub(crate) struct FtGeneric {
153    pub(crate) data: *mut c_void,
154    pub(crate) finalizer: *mut c_void,
155}
156
157#[cfg(any(target_os = "linux", target_os = "android"))]
158#[repr(C)]
159#[derive(Clone, Copy)]
160pub(crate) struct FtBBox {
161    pub(crate) x_min: isize,
162    pub(crate) y_min: isize,
163    pub(crate) x_max: isize,
164    pub(crate) y_max: isize,
165}
166
167#[cfg(any(target_os = "linux", target_os = "android"))]
168#[repr(C)]
169#[derive(Clone, Copy)]
170pub(crate) struct FtGlyphMetrics {
171    pub(crate) width: isize,
172    pub(crate) height: isize,
173    pub(crate) hori_bearing_x: isize,
174    pub(crate) hori_bearing_y: isize,
175    pub(crate) hori_advance: isize,
176    pub(crate) vert_bearing_x: isize,
177    pub(crate) vert_bearing_y: isize,
178    pub(crate) vert_advance: isize,
179}
180
181#[cfg(any(target_os = "linux", target_os = "android"))]
182#[repr(C)]
183#[derive(Clone, Copy)]
184pub(crate) struct FtSizeMetrics {
185    pub(crate) x_ppem: u16,
186    pub(crate) y_ppem: u16,
187    pub(crate) x_scale: isize,
188    pub(crate) y_scale: isize,
189    pub(crate) ascender: isize,
190    pub(crate) descender: isize,
191    pub(crate) height: isize,
192    pub(crate) max_advance: isize,
193}
194
195#[cfg(any(target_os = "linux", target_os = "android"))]
196#[repr(C)]
197#[derive(Clone, Copy)]
198pub(crate) struct FtSizeRec {
199    pub(crate) face: *mut c_void,
200    pub(crate) generic: FtGeneric,
201    pub(crate) metrics: FtSizeMetrics,
202    pub(crate) internal: *mut c_void,
203}
204
205#[cfg(any(target_os = "linux", target_os = "android"))]
206#[repr(C)]
207#[derive(Clone, Copy)]
208pub(crate) struct FtGlyphSlotRec {
209    pub(crate) library: *mut c_void,
210    pub(crate) face: *mut c_void,
211    pub(crate) next: *mut c_void,
212    pub(crate) glyph_index: u32,
213    pub(crate) generic: FtGeneric,
214    pub(crate) metrics: FtGlyphMetrics,
215    pub(crate) linear_hori_advance: isize,
216    pub(crate) linear_vert_advance: isize,
217    pub(crate) advance: FtVector,
218    pub(crate) format: u32,
219    pub(crate) bitmap: FtBitmap,
220    pub(crate) bitmap_left: i32,
221    pub(crate) bitmap_top: i32,
222}
223
224#[cfg(any(target_os = "linux", target_os = "android"))]
225#[repr(C)]
226#[derive(Clone, Copy)]
227pub(crate) struct FtFaceRec {
228    pub(crate) num_faces: isize,
229    pub(crate) face_index: isize,
230    pub(crate) face_flags: isize,
231    pub(crate) style_flags: isize,
232    pub(crate) num_glyphs: isize,
233    pub(crate) family_name: *const c_char,
234    pub(crate) style_name: *const c_char,
235    pub(crate) num_fixed_sizes: i32,
236    pub(crate) available_sizes: *mut c_void,
237    pub(crate) num_charmaps: i32,
238    pub(crate) charmaps: *mut c_void,
239    pub(crate) generic: FtGeneric,
240    pub(crate) bbox: FtBBox,
241    pub(crate) units_per_em: u16,
242    pub(crate) ascender: i16,
243    pub(crate) descender: i16,
244    pub(crate) height: i16,
245    pub(crate) max_advance_width: i16,
246    pub(crate) max_advance_height: i16,
247    pub(crate) underline_position: i16,
248    pub(crate) underline_thickness: i16,
249    pub(crate) glyph: *const FtGlyphSlotRec,
250    pub(crate) size: *const FtSizeRec,
251}
252
253#[cfg(any(target_os = "linux", target_os = "android"))]
254pub(crate) struct FreeTypeRuntime {
255    pub(crate) regular_face: *mut FtFaceRec,
256    pub(crate) bold_face: *mut FtFaceRec,
257    pub(crate) mono_face: *mut FtFaceRec,
258    pub(crate) mono_bold_face: *mut FtFaceRec,
259    pub(crate) cjk_face: *mut FtFaceRec,
260    pub(crate) set_pixel_sizes: FtSetPixelSizesFn,
261    pub(crate) get_char_index: FtGetCharIndexFn,
262    pub(crate) load_glyph: FtLoadGlyphFn,
263}