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#[derive(Clone, Copy, Debug, Default, Eq, Getter, New, PartialEq)]
49pub struct GlyphStripPlacement {
50 #[get(type(copy))]
52 pub(crate) key: GlyphKey,
53 #[get(type(copy))]
55 pub(crate) x: u32,
56 #[get(type(copy))]
58 pub(crate) y: u32,
59 #[get(type(copy))]
61 pub(crate) width: u32,
62 #[get(type(copy))]
64 pub(crate) height: u32,
65 #[get(type(copy))]
67 pub(crate) advance: u32,
68}
69
70#[derive(Clone, Debug, Default, Eq, Getter, New, PartialEq)]
72pub struct WebGlyphStripBatch {
73 #[get(type(copy))]
75 pub(crate) strip_width: u32,
76 #[get(type(copy))]
78 pub(crate) strip_height: u32,
79 pub(crate) placements: Vec<GlyphStripPlacement>,
81 #[get(type(copy))]
83 pub(crate) readbacks_performed: u32,
84}
85
86#[derive(Clone, Debug, Default, Getter)]
88pub struct WebCssFontCache {
89 #[get(skip)]
91 pub(crate) entries: Vec<(u32, String)>,
92 #[get(skip)]
94 pub(crate) evict_cursor: usize,
95 #[get(type(copy))]
97 pub(crate) hits: u64,
98 #[get(type(copy))]
100 pub(crate) misses: u64,
101}
102
103#[cfg(any(target_os = "macos", target_os = "ios"))]
104#[repr(C)]
105#[derive(Clone, Copy)]
106pub(crate) struct CtRange {
107 pub(crate) location: isize,
108 pub(crate) length: isize,
109}
110
111#[cfg(any(target_os = "macos", target_os = "ios"))]
112#[repr(C)]
113#[derive(Clone, Copy)]
114pub(crate) struct CtPoint {
115 pub(crate) x: f64,
116 pub(crate) y: f64,
117}
118
119#[cfg(any(target_os = "macos", target_os = "ios"))]
120#[repr(C)]
121#[derive(Clone, Copy)]
122pub(crate) struct CtSize {
123 pub(crate) width: f64,
124 pub(crate) height: f64,
125}
126
127#[cfg(any(target_os = "macos", target_os = "ios"))]
128#[repr(C)]
129#[derive(Clone, Copy)]
130pub(crate) struct CtRect {
131 pub(crate) origin: CtPoint,
132 pub(crate) size: CtSize,
133}
134
135#[cfg(any(target_os = "macos", target_os = "ios"))]
137#[derive(Clone, Copy)]
138pub(crate) struct CoreTextFontCacheEntry {
139 pub(crate) style_sig: u32,
141 pub(crate) referenced: bool,
143 pub(crate) font: *mut c_void,
145 pub(crate) ascent: f64,
147 pub(crate) descent: f64,
149 pub(crate) fallback_fonts: [*mut c_void; CORETEXT_FALLBACK_SLOTS],
151}
152
153#[cfg(any(target_os = "macos", target_os = "ios"))]
155pub(crate) struct CoreTextFontCache {
156 pub(crate) gray_space: *mut c_void,
158 pub(crate) scratch_ctx: *mut c_void,
160 pub(crate) scratch_buf: Vec<u8>,
162 pub(crate) scratch_w: usize,
164 pub(crate) scratch_h: usize,
166 pub(crate) count: usize,
168 pub(crate) clock_hand: usize,
170 pub(crate) index: [u8; CORETEXT_FONT_INDEX_CAP],
172 pub(crate) slots: [CoreTextFontCacheEntry; CORETEXT_FONT_CACHE_SLOTS],
174}
175
176#[cfg(target_os = "windows")]
178#[repr(C)]
179#[derive(Clone, Copy)]
180pub(crate) struct WinGuid {
181 pub(crate) data1: u32,
182 pub(crate) data2: u16,
183 pub(crate) data3: u16,
184 pub(crate) data4: [u8; 8],
185}
186
187#[cfg(target_os = "windows")]
189#[derive(Clone, Copy)]
190pub(crate) struct DirectWriteLib {
191 pub(crate) create_factory: WinDWriteCreateFactoryFn,
193}
194
195#[cfg(target_os = "windows")]
197#[derive(Clone, Copy)]
198pub(crate) struct Win32FontCacheEntry {
199 pub(crate) style_sig: u32,
201 pub(crate) referenced: bool,
203 pub(crate) hfont: *mut c_void,
205 pub(crate) ascent: i32,
207 pub(crate) descent: i32,
209}
210
211#[cfg(target_os = "windows")]
213pub(crate) struct Win32FontCache {
214 pub(crate) hdc: *mut c_void,
216 pub(crate) dwrite_attempted: bool,
218 pub(crate) dwrite_factory: *mut c_void,
220 pub(crate) count: usize,
222 pub(crate) clock_hand: usize,
224 pub(crate) index: [u8; WIN32_FONT_INDEX_CAP],
226 pub(crate) slots: [Win32FontCacheEntry; WIN32_FONT_CACHE_SLOTS],
228 pub(crate) raw_buf: Vec<u8>,
230}
231
232#[cfg(target_os = "windows")]
233#[repr(C)]
234#[derive(Clone, Copy, Default)]
235pub(crate) struct WinFixed {
236 pub(crate) fract: u16,
237 pub(crate) value: i16,
238}
239
240#[cfg(target_os = "windows")]
241#[repr(C)]
242#[derive(Clone, Copy, Default)]
243pub(crate) struct WinMat2 {
244 pub(crate) em11: WinFixed,
245 pub(crate) em12: WinFixed,
246 pub(crate) em21: WinFixed,
247 pub(crate) em22: WinFixed,
248}
249
250#[cfg(target_os = "windows")]
251#[repr(C)]
252#[derive(Clone, Copy, Default)]
253pub(crate) struct WinGlyphMetrics {
254 pub(crate) black_box_x: u32,
255 pub(crate) black_box_y: u32,
256 pub(crate) glyph_origin_x: i32,
257 pub(crate) glyph_origin_y: i32,
258 pub(crate) cell_inc_x: i16,
259 pub(crate) cell_inc_y: i16,
260}
261
262#[cfg(target_os = "windows")]
263#[repr(C)]
264#[derive(Clone, Copy, Default)]
265pub(crate) struct WinTextMetricW {
266 pub(crate) tm_height: i32,
267 pub(crate) tm_ascent: i32,
268 pub(crate) tm_descent: i32,
269 pub(crate) tm_internal_leading: i32,
270 pub(crate) tm_external_leading: i32,
271 pub(crate) tm_ave_char_width: i32,
272 pub(crate) tm_max_char_width: i32,
273 pub(crate) tm_weight: i32,
274 pub(crate) tm_overhang: i32,
275 pub(crate) tm_digitized_aspect_x: i32,
276 pub(crate) tm_digitized_aspect_y: i32,
277 pub(crate) tm_first_char: u16,
278 pub(crate) tm_last_char: u16,
279 pub(crate) tm_default_char: u16,
280 pub(crate) tm_break_char: u16,
281 pub(crate) tm_italic: u8,
282 pub(crate) tm_underlined: u8,
283 pub(crate) tm_struck_out: u8,
284 pub(crate) tm_pitch_and_family: u8,
285 pub(crate) tm_char_set: u8,
286}
287
288#[cfg(any(target_os = "linux", target_os = "android"))]
289#[repr(C)]
290#[derive(Clone, Copy)]
291pub(crate) struct FtBitmap {
292 pub(crate) rows: u32,
293 pub(crate) width: u32,
294 pub(crate) pitch: i32,
295 pub(crate) buffer: *const u8,
296 pub(crate) num_grays: u16,
297 pub(crate) pixel_mode: u8,
298 pub(crate) palette_mode: u8,
299 pub(crate) palette: *mut c_void,
300}
301
302#[cfg(any(target_os = "linux", target_os = "android"))]
303#[repr(C)]
304#[derive(Clone, Copy)]
305pub(crate) struct FtVector {
306 pub(crate) x: isize,
307 pub(crate) y: isize,
308}
309
310#[cfg(any(target_os = "linux", target_os = "android"))]
311#[repr(C)]
312#[derive(Clone, Copy)]
313pub(crate) struct FtGeneric {
314 pub(crate) data: *mut c_void,
315 pub(crate) finalizer: *mut c_void,
316}
317
318#[cfg(any(target_os = "linux", target_os = "android"))]
319#[repr(C)]
320#[derive(Clone, Copy)]
321pub(crate) struct FtBBox {
322 pub(crate) x_min: isize,
323 pub(crate) y_min: isize,
324 pub(crate) x_max: isize,
325 pub(crate) y_max: isize,
326}
327
328#[cfg(any(target_os = "linux", target_os = "android"))]
329#[repr(C)]
330#[derive(Clone, Copy)]
331pub(crate) struct FtGlyphMetrics {
332 pub(crate) width: isize,
333 pub(crate) height: isize,
334 pub(crate) hori_bearing_x: isize,
335 pub(crate) hori_bearing_y: isize,
336 pub(crate) hori_advance: isize,
337 pub(crate) vert_bearing_x: isize,
338 pub(crate) vert_bearing_y: isize,
339 pub(crate) vert_advance: isize,
340}
341
342#[cfg(any(target_os = "linux", target_os = "android"))]
343#[repr(C)]
344#[derive(Clone, Copy)]
345pub(crate) struct FtSizeMetrics {
346 pub(crate) x_ppem: u16,
347 pub(crate) y_ppem: u16,
348 pub(crate) x_scale: isize,
349 pub(crate) y_scale: isize,
350 pub(crate) ascender: isize,
351 pub(crate) descender: isize,
352 pub(crate) height: isize,
353 pub(crate) max_advance: isize,
354}
355
356#[cfg(any(target_os = "linux", target_os = "android"))]
357#[repr(C)]
358#[derive(Clone, Copy)]
359pub(crate) struct FtSizeRec {
360 pub(crate) face: *mut c_void,
361 pub(crate) generic: FtGeneric,
362 pub(crate) metrics: FtSizeMetrics,
363 pub(crate) internal: *mut c_void,
364}
365
366#[cfg(any(target_os = "linux", target_os = "android"))]
367#[repr(C)]
368#[derive(Clone, Copy)]
369pub(crate) struct FtGlyphSlotRec {
370 pub(crate) library: *mut c_void,
371 pub(crate) face: *mut c_void,
372 pub(crate) next: *mut c_void,
373 pub(crate) glyph_index: u32,
374 pub(crate) generic: FtGeneric,
375 pub(crate) metrics: FtGlyphMetrics,
376 pub(crate) linear_hori_advance: isize,
377 pub(crate) linear_vert_advance: isize,
378 pub(crate) advance: FtVector,
379 pub(crate) format: u32,
380 pub(crate) bitmap: FtBitmap,
381 pub(crate) bitmap_left: i32,
382 pub(crate) bitmap_top: i32,
383}
384
385#[cfg(any(target_os = "linux", target_os = "android"))]
386#[repr(C)]
387#[derive(Clone, Copy)]
388pub(crate) struct FtFaceRec {
389 pub(crate) num_faces: isize,
390 pub(crate) face_index: isize,
391 pub(crate) face_flags: isize,
392 pub(crate) style_flags: isize,
393 pub(crate) num_glyphs: isize,
394 pub(crate) family_name: *const c_char,
395 pub(crate) style_name: *const c_char,
396 pub(crate) num_fixed_sizes: i32,
397 pub(crate) available_sizes: *mut c_void,
398 pub(crate) num_charmaps: i32,
399 pub(crate) charmaps: *mut c_void,
400 pub(crate) generic: FtGeneric,
401 pub(crate) bbox: FtBBox,
402 pub(crate) units_per_em: u16,
403 pub(crate) ascender: i16,
404 pub(crate) descender: i16,
405 pub(crate) height: i16,
406 pub(crate) max_advance_width: i16,
407 pub(crate) max_advance_height: i16,
408 pub(crate) underline_position: i16,
409 pub(crate) underline_thickness: i16,
410 pub(crate) glyph: *const FtGlyphSlotRec,
411 pub(crate) size: *const FtSizeRec,
412}
413
414#[cfg(any(target_os = "linux", target_os = "android"))]
416#[derive(Clone, Copy)]
417pub(crate) struct FreeTypeLib {
418 pub(crate) handle_addr: usize,
420 pub(crate) init: FtInitFreeTypeFn,
422 pub(crate) done: FtDoneFreeTypeFn,
424 pub(crate) new_face: FtNewFaceFn,
426 pub(crate) done_face: Option<FtDoneFaceFn>,
428 pub(crate) set_pixel_sizes: FtSetPixelSizesFn,
430 pub(crate) get_char_index: FtGetCharIndexFn,
432 pub(crate) load_glyph: FtLoadGlyphFn,
434}
435
436#[cfg(target_os = "android")]
438#[derive(Clone, Copy)]
439pub(crate) struct AndroidFontMatcherLib {
440 pub(crate) handle_addr: usize,
442 pub(crate) create: AFontMatcherCreateFn,
444 pub(crate) destroy: AFontMatcherDestroyFn,
446 pub(crate) set_style: AFontMatcherSetStyleFn,
448 pub(crate) match_font: AFontMatcherMatchFn,
450 pub(crate) font_file_path: AFontGetFilePathFn,
452 pub(crate) collection_index: AFontGetCollectionIndexFn,
454 pub(crate) font_close: AFontCloseFn,
456}
457
458#[cfg(target_os = "android")]
460#[derive(Clone, Copy)]
461pub(crate) struct FtAndroidFallbackFace {
462 pub(crate) path_hash: u64,
464 pub(crate) collection_index: u32,
466 pub(crate) referenced: bool,
468 pub(crate) slot: FtLazyFace,
470}
471
472#[cfg(any(target_os = "linux", target_os = "android"))]
474#[derive(Clone, Copy)]
475pub(crate) struct FtLazyFace {
476 pub(crate) probed: bool,
478 pub(crate) face: *mut FtFaceRec,
480 pub(crate) last_size_px: u32,
482}
483
484#[cfg(any(target_os = "linux", target_os = "android"))]
486pub(crate) struct FreeTypeRuntime {
487 pub(crate) library: *mut c_void,
489 pub(crate) done: FtDoneFreeTypeFn,
491 pub(crate) new_face: FtNewFaceFn,
493 pub(crate) done_face: Option<FtDoneFaceFn>,
495 pub(crate) regular: FtLazyFace,
497 pub(crate) bold: FtLazyFace,
499 pub(crate) mono: FtLazyFace,
501 pub(crate) mono_bold: FtLazyFace,
503 pub(crate) cjk: FtLazyFace,
505 pub(crate) set_pixel_sizes: FtSetPixelSizesFn,
507 pub(crate) get_char_index: FtGetCharIndexFn,
509 pub(crate) load_glyph: FtLoadGlyphFn,
511 #[cfg(target_os = "android")]
513 pub(crate) matcher: *mut c_void,
514 #[cfg(target_os = "android")]
516 pub(crate) android_fallbacks: [FtAndroidFallbackFace; ANDROID_FALLBACK_CACHE_SLOTS],
517 #[cfg(target_os = "android")]
519 pub(crate) android_fallback_hand: usize,
520}
521
522#[cfg(target_arch = "wasm32")]
524pub(crate) struct WebFontScratch {
525 pub(crate) readback_canvas: Option<HtmlCanvasElement>,
527 pub(crate) readback_ctx2d: Option<CanvasRenderingContext2d>,
529 pub(crate) readback_width: u32,
531 pub(crate) readback_height: u32,
533 pub(crate) readback_last_sig: u32,
535 pub(crate) gpu_canvas: Option<HtmlCanvasElement>,
537 pub(crate) gpu_ctx2d: Option<CanvasRenderingContext2d>,
539 pub(crate) gpu_width: u32,
541 pub(crate) gpu_height: u32,
543 pub(crate) gpu_last_sig: u32,
545 pub(crate) css_cache: WebCssFontCache,
547 pub(crate) total_readbacks: u64,
549 pub(crate) total_gpu_strip_batches: u64,
551}