1use std::path::PathBuf;
4
5use serde::{Deserialize, Serialize};
6use zng_task::channel::IpcBytes;
7use zng_unit::Px;
8
9use crate::{config::FontAntiAliasing, declare_id};
10
11declare_id! {
12 pub struct FontFaceId(_);
16
17 pub struct FontId(_);
21}
22
23#[derive(Default, Debug, PartialEq, Clone, Deserialize, Serialize)]
25#[non_exhaustive]
26pub struct FontOptions {
27 pub aa: FontAntiAliasing,
31
32 pub synthetic_bold: bool,
34 pub synthetic_oblique: bool,
36}
37impl FontOptions {
38 pub fn new(aa: FontAntiAliasing, synthetic_bold: bool, synthetic_oblique: bool) -> Self {
40 Self {
41 aa,
42 synthetic_bold,
43 synthetic_oblique,
44 }
45 }
46}
47
48pub type GlyphOptions = FontOptions;
50
51pub type FontVariationName = [u8; 4];
53
54#[repr(C)]
56#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
57#[non_exhaustive]
58pub struct GlyphInstance {
59 pub index: GlyphIndex,
61 pub point: euclid::Point2D<f32, Px>,
63}
64impl GlyphInstance {
65 pub fn new(index: GlyphIndex, point: euclid::Point2D<f32, Px>) -> Self {
67 Self { index, point }
68 }
69}
70
71pub type GlyphIndex = u32;
73
74#[derive(Clone, Debug, Deserialize, Serialize)]
76pub enum IpcFontBytes {
77 Bytes(IpcBytes),
79 System(PathBuf),
84}