1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GlyphId(u16);
impl GlyphId {
pub const NOTDEF: GlyphId = GlyphId(0);
pub const fn new(raw: u16) -> Self {
GlyphId(raw)
}
pub const fn to_u16(self) -> u16 {
self.0
}
pub const fn to_be_bytes(self) -> [u8; 2] {
self.0.to_be_bytes()
}
}
impl Default for GlyphId {
fn default() -> Self {
GlyphId::NOTDEF
}
}
impl std::fmt::Display for GlyphId {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "GID_{}", self.0)
}
}
crate::newtype_scalar!(GlyphId, [u8; 2]);