1use super::*;
2
3#[derive(Clone, Debug, Eq, Getter, New, PartialEq)]
5pub struct SystemFontInfo {
6 #[get(type(copy))]
8 pub(crate) backend: FontRenderBackend,
9 pub(crate) family_name: String,
11 #[get(type(copy))]
13 pub(crate) supports_unicode: bool,
14 #[get(type(copy))]
16 pub(crate) supports_antialiasing: bool,
17}
18
19#[derive(Clone, Debug, Getter)]
21pub struct NativeSystemFont {
22 pub(crate) info: SystemFontInfo,
24 #[get(type(copy))]
26 pub(crate) deterministic_only: bool,
27}
28
29#[derive(Clone, Debug, Getter, New)]
31pub struct PackedGlyphAtlas {
32 #[get(type(copy))]
34 pub(crate) width: u32,
35 #[get(type(copy))]
37 pub(crate) height: u32,
38 pub(crate) pixels: Vec<u8>,
40 pub(crate) regions: HashMap<GlyphKey, (u32, u32, u32, u32)>,
42 #[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(any(target_os = "macos", target_os = "ios"))]
73#[derive(Clone, Copy)]
74pub(crate) struct CoreTextFontCacheEntry {
75 pub(crate) style_sig: u32,
77 pub(crate) font: *mut c_void,
79 pub(crate) ascent: f64,
81 pub(crate) descent: f64,
83 pub(crate) fallback_fonts: [*mut c_void; CORETEXT_FALLBACK_SLOTS],
85}
86
87#[cfg(any(target_os = "macos", target_os = "ios"))]
89pub(crate) struct CoreTextFontCache {
90 pub(crate) gray_space: *mut c_void,
92 pub(crate) scratch_ctx: *mut c_void,
94 pub(crate) scratch_buf: Vec<u8>,
96 pub(crate) scratch_w: usize,
98 pub(crate) scratch_h: usize,
100 pub(crate) fonts: Vec<CoreTextFontCacheEntry>,
102}
103
104#[cfg(target_os = "windows")]
106#[derive(Clone, Copy)]
107pub(crate) struct Win32FontCacheEntry {
108 pub(crate) style_sig: u32,
110 pub(crate) hfont: *mut c_void,
112 pub(crate) ascent: i32,
114 pub(crate) descent: i32,
116}
117
118#[cfg(target_os = "windows")]
120pub(crate) struct Win32FontCache {
121 pub(crate) hdc: *mut c_void,
123 pub(crate) fonts: Vec<Win32FontCacheEntry>,
125 pub(crate) raw_buf: Vec<u8>,
127}
128
129#[cfg(target_os = "windows")]
130#[repr(C)]
131#[derive(Clone, Copy, Default)]
132pub(crate) struct WinFixed {
133 pub(crate) fract: u16,
134 pub(crate) value: i16,
135}
136
137#[cfg(target_os = "windows")]
138#[repr(C)]
139#[derive(Clone, Copy, Default)]
140pub(crate) struct WinMat2 {
141 pub(crate) em11: WinFixed,
142 pub(crate) em12: WinFixed,
143 pub(crate) em21: WinFixed,
144 pub(crate) em22: WinFixed,
145}
146
147#[cfg(target_os = "windows")]
148#[repr(C)]
149#[derive(Clone, Copy, Default)]
150pub(crate) struct WinGlyphMetrics {
151 pub(crate) black_box_x: u32,
152 pub(crate) black_box_y: u32,
153 pub(crate) glyph_origin_x: i32,
154 pub(crate) glyph_origin_y: i32,
155 pub(crate) cell_inc_x: i16,
156 pub(crate) cell_inc_y: i16,
157}
158
159#[cfg(target_os = "windows")]
160#[repr(C)]
161#[derive(Clone, Copy, Default)]
162pub(crate) struct WinTextMetricW {
163 pub(crate) tm_height: i32,
164 pub(crate) tm_ascent: i32,
165 pub(crate) tm_descent: i32,
166 pub(crate) tm_internal_leading: i32,
167 pub(crate) tm_external_leading: i32,
168 pub(crate) tm_ave_char_width: i32,
169 pub(crate) tm_max_char_width: i32,
170 pub(crate) tm_weight: i32,
171 pub(crate) tm_overhang: i32,
172 pub(crate) tm_digitized_aspect_x: i32,
173 pub(crate) tm_digitized_aspect_y: i32,
174 pub(crate) tm_first_char: u16,
175 pub(crate) tm_last_char: u16,
176 pub(crate) tm_default_char: u16,
177 pub(crate) tm_break_char: u16,
178 pub(crate) tm_italic: u8,
179 pub(crate) tm_underlined: u8,
180 pub(crate) tm_struck_out: u8,
181 pub(crate) tm_pitch_and_family: u8,
182 pub(crate) tm_char_set: u8,
183}
184
185#[cfg(any(target_os = "linux", target_os = "android"))]
186#[repr(C)]
187#[derive(Clone, Copy)]
188pub(crate) struct FtBitmap {
189 pub(crate) rows: u32,
190 pub(crate) width: u32,
191 pub(crate) pitch: i32,
192 pub(crate) buffer: *const u8,
193 pub(crate) num_grays: u16,
194 pub(crate) pixel_mode: u8,
195 pub(crate) palette_mode: u8,
196 pub(crate) palette: *mut c_void,
197}
198
199#[cfg(any(target_os = "linux", target_os = "android"))]
200#[repr(C)]
201#[derive(Clone, Copy)]
202pub(crate) struct FtVector {
203 pub(crate) x: isize,
204 pub(crate) y: isize,
205}
206
207#[cfg(any(target_os = "linux", target_os = "android"))]
208#[repr(C)]
209#[derive(Clone, Copy)]
210pub(crate) struct FtGeneric {
211 pub(crate) data: *mut c_void,
212 pub(crate) finalizer: *mut c_void,
213}
214
215#[cfg(any(target_os = "linux", target_os = "android"))]
216#[repr(C)]
217#[derive(Clone, Copy)]
218pub(crate) struct FtBBox {
219 pub(crate) x_min: isize,
220 pub(crate) y_min: isize,
221 pub(crate) x_max: isize,
222 pub(crate) y_max: isize,
223}
224
225#[cfg(any(target_os = "linux", target_os = "android"))]
226#[repr(C)]
227#[derive(Clone, Copy)]
228pub(crate) struct FtGlyphMetrics {
229 pub(crate) width: isize,
230 pub(crate) height: isize,
231 pub(crate) hori_bearing_x: isize,
232 pub(crate) hori_bearing_y: isize,
233 pub(crate) hori_advance: isize,
234 pub(crate) vert_bearing_x: isize,
235 pub(crate) vert_bearing_y: isize,
236 pub(crate) vert_advance: isize,
237}
238
239#[cfg(any(target_os = "linux", target_os = "android"))]
240#[repr(C)]
241#[derive(Clone, Copy)]
242pub(crate) struct FtSizeMetrics {
243 pub(crate) x_ppem: u16,
244 pub(crate) y_ppem: u16,
245 pub(crate) x_scale: isize,
246 pub(crate) y_scale: isize,
247 pub(crate) ascender: isize,
248 pub(crate) descender: isize,
249 pub(crate) height: isize,
250 pub(crate) max_advance: isize,
251}
252
253#[cfg(any(target_os = "linux", target_os = "android"))]
254#[repr(C)]
255#[derive(Clone, Copy)]
256pub(crate) struct FtSizeRec {
257 pub(crate) face: *mut c_void,
258 pub(crate) generic: FtGeneric,
259 pub(crate) metrics: FtSizeMetrics,
260 pub(crate) internal: *mut c_void,
261}
262
263#[cfg(any(target_os = "linux", target_os = "android"))]
264#[repr(C)]
265#[derive(Clone, Copy)]
266pub(crate) struct FtGlyphSlotRec {
267 pub(crate) library: *mut c_void,
268 pub(crate) face: *mut c_void,
269 pub(crate) next: *mut c_void,
270 pub(crate) glyph_index: u32,
271 pub(crate) generic: FtGeneric,
272 pub(crate) metrics: FtGlyphMetrics,
273 pub(crate) linear_hori_advance: isize,
274 pub(crate) linear_vert_advance: isize,
275 pub(crate) advance: FtVector,
276 pub(crate) format: u32,
277 pub(crate) bitmap: FtBitmap,
278 pub(crate) bitmap_left: i32,
279 pub(crate) bitmap_top: i32,
280}
281
282#[cfg(any(target_os = "linux", target_os = "android"))]
283#[repr(C)]
284#[derive(Clone, Copy)]
285pub(crate) struct FtFaceRec {
286 pub(crate) num_faces: isize,
287 pub(crate) face_index: isize,
288 pub(crate) face_flags: isize,
289 pub(crate) style_flags: isize,
290 pub(crate) num_glyphs: isize,
291 pub(crate) family_name: *const c_char,
292 pub(crate) style_name: *const c_char,
293 pub(crate) num_fixed_sizes: i32,
294 pub(crate) available_sizes: *mut c_void,
295 pub(crate) num_charmaps: i32,
296 pub(crate) charmaps: *mut c_void,
297 pub(crate) generic: FtGeneric,
298 pub(crate) bbox: FtBBox,
299 pub(crate) units_per_em: u16,
300 pub(crate) ascender: i16,
301 pub(crate) descender: i16,
302 pub(crate) height: i16,
303 pub(crate) max_advance_width: i16,
304 pub(crate) max_advance_height: i16,
305 pub(crate) underline_position: i16,
306 pub(crate) underline_thickness: i16,
307 pub(crate) glyph: *const FtGlyphSlotRec,
308 pub(crate) size: *const FtSizeRec,
309}
310
311#[cfg(any(target_os = "linux", target_os = "android"))]
313#[derive(Clone, Copy)]
314pub(crate) struct FtLazyFace {
315 pub(crate) probed: bool,
317 pub(crate) face: *mut FtFaceRec,
319 pub(crate) last_size_px: u32,
321}
322
323#[cfg(any(target_os = "linux", target_os = "android"))]
325pub(crate) struct FreeTypeRuntime {
326 pub(crate) library: *mut c_void,
328 pub(crate) new_face: FtNewFaceFn,
330 pub(crate) regular: FtLazyFace,
332 pub(crate) bold: FtLazyFace,
334 pub(crate) mono: FtLazyFace,
336 pub(crate) mono_bold: FtLazyFace,
338 pub(crate) cjk: FtLazyFace,
340 pub(crate) set_pixel_sizes: FtSetPixelSizesFn,
342 pub(crate) get_char_index: FtGetCharIndexFn,
344 pub(crate) load_glyph: FtLoadGlyphFn,
346}
347
348#[cfg(target_arch = "wasm32")]
350pub(crate) struct WebFontScratch {
351 pub(crate) canvas: Option<HtmlCanvasElement>,
353 pub(crate) ctx2d: Option<CanvasRenderingContext2d>,
355 pub(crate) width: u32,
357 pub(crate) height: u32,
359 pub(crate) last_font: String,
361}