1use std::path::PathBuf;
4
5use serde::{Deserialize, Serialize};
6use zng_unit::Px;
7
8use crate::{config::FontAntiAliasing, declare_id, ipc::IpcBytes};
9
10declare_id! {
11 pub struct FontFaceId(_);
15
16 pub struct FontId(_);
20}
21
22#[derive(Default, Debug, PartialEq, Clone, Deserialize, Serialize)]
24#[non_exhaustive]
25pub struct FontOptions {
26 pub aa: FontAntiAliasing,
30
31 pub synthetic_bold: bool,
33 pub synthetic_oblique: bool,
35}
36impl FontOptions {
37 pub fn new(aa: FontAntiAliasing, synthetic_bold: bool, synthetic_oblique: bool) -> Self {
39 Self {
40 aa,
41 synthetic_bold,
42 synthetic_oblique,
43 }
44 }
45}
46
47pub type GlyphOptions = FontOptions;
49
50pub type FontVariationName = [u8; 4];
52
53#[repr(C)]
55#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
56#[non_exhaustive]
57pub struct GlyphInstance {
58 pub index: GlyphIndex,
60 pub point: euclid::Point2D<f32, Px>,
62}
63impl GlyphInstance {
64 pub fn new(index: GlyphIndex, point: euclid::Point2D<f32, Px>) -> Self {
66 Self { index, point }
67 }
68}
69
70pub type GlyphIndex = u32;
72
73#[derive(Clone, Debug, Deserialize, Serialize)]
75pub enum IpcFontBytes {
76 Bytes(IpcBytes),
78 System(PathBuf),
83}