artery_font/
enums.rs

1
2#[derive(Debug, Clone, Eq, PartialEq)]
3pub enum MetadataFormat {
4    None,
5    PlainText(String),
6    Json(String)
7}
8
9#[derive(Debug, Copy, Clone, Eq, PartialEq)]
10pub enum CodepointType {
11    Unspecified,
12    Unicode,
13    Indexed,
14    Iconographic
15}
16
17impl Default for CodepointType {
18    fn default() -> Self {
19        Self::Unspecified
20    }
21}
22
23impl From<u32> for CodepointType {
24    fn from(i: u32) -> Self {
25        match i {
26            1 => Self::Unicode,
27            2 => Self::Indexed,
28            14 => Self::Iconographic,
29            _ => Self::default()
30        }
31    }
32}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq)]
35pub enum ImageType {
36    None,
37    SrgbImage,
38    LinearMask,
39    MaskedSrgbImage,
40    Sdf,
41    Psdf,
42    Msdf,
43    Mtsdf,
44    MixedContent
45}
46
47impl Default for ImageType {
48    fn default() -> Self {
49        Self::None
50    }
51}
52
53impl From<u32> for ImageType {
54    fn from(i: u32) -> Self {
55        match i {
56            1 => Self::SrgbImage,
57            2 => Self::LinearMask,
58            3 => Self::MaskedSrgbImage,
59            4 => Self::Sdf,
60            5 => Self::Psdf,
61            6 => Self::Msdf,
62            7 => Self::Mtsdf,
63            255 => Self::MixedContent,
64            _ => Self::default()
65        }
66    }
67}
68
69#[derive(Debug, Copy, Clone, Eq, PartialEq)]
70pub enum ImageEncoding {
71    UnknownEncoding,
72    RawBinary,
73    Bmp,
74    Tiff,
75    Png,
76    Tga
77}
78
79impl Default for ImageEncoding {
80    fn default() -> Self {
81        Self::UnknownEncoding
82    }
83}
84
85impl From<u32> for ImageEncoding {
86    fn from(i: u32) -> Self {
87        match i {
88            1 => Self::RawBinary,
89            4 => Self::Bmp,
90            5 => Self::Tiff,
91            8 => Self::Png,
92            9 => Self::Tga,
93            _ => Self::default()
94        }
95    }
96}
97
98
99#[derive(Debug, Copy, Clone, Eq, PartialEq)]
100pub enum PixelFormat {
101    Unknown,
102    Boolean1,
103    Unsigned8,
104    Float32
105}
106
107impl Default for PixelFormat {
108    fn default() -> Self {
109        Self::Unknown
110    }
111}
112
113impl From<u32> for PixelFormat {
114    fn from(i: u32) -> Self {
115        match i {
116            1 => Self::Boolean1,
117            8 => Self::Unsigned8,
118            32 => Self::Float32,
119            _ => Self::default()
120        }
121    }
122}
123
124impl PixelFormat {
125    pub fn bits(self) -> usize {
126        match self {
127            PixelFormat::Unknown => 0,
128            PixelFormat::Boolean1 => 1,
129            PixelFormat::Unsigned8 => 8,
130            PixelFormat::Float32 => 32,
131        }
132    }
133}
134
135#[derive(Debug, Copy, Clone, Eq, PartialEq)]
136pub enum ImageOrientation {
137    BottomUp = -1,
138    Unknown,
139    TopDown = 1,
140}
141
142impl Default for ImageOrientation {
143    fn default() -> Self {
144        Self::Unknown
145    }
146}
147
148impl From<i32> for ImageOrientation {
149    fn from(i: i32) -> Self {
150        match i {
151            -1 => Self::BottomUp,
152             1 => Self::TopDown,
153             _ => Self::default()
154        }
155    }
156}