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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
mod builder;
pub use builder::Builder;
use crate::{Number, Offset};
#[derive(Clone, Debug)]
pub struct Glyph {
pub advance_width: Number,
pub bounding_box: (Number, Number, Number, Number),
pub side_bearings: (Number, Number),
pub contours: Vec<Contour>,
}
#[derive(Clone, Debug, Default)]
pub struct Contour {
pub offset: Offset,
pub position: Offset,
pub segments: Vec<Segment>,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Segment {
Linear(Offset),
Quadratic(Offset, Offset),
Cubic(Offset, Offset, Offset),
}
impl Glyph {
#[inline]
pub fn height(&self) -> Number {
self.bounding_box.3 - self.bounding_box.1
}
#[inline]
pub fn width(&self) -> Number {
self.bounding_box.2 - self.bounding_box.0
}
}
dereference! { Glyph::contours => [Contour] }
dereference! { Contour::segments => [Segment] }
impl Default for Glyph {
#[inline]
fn default() -> Self {
Glyph {
advance_width: Number::NAN,
bounding_box: (Number::NAN, Number::NAN, Number::NAN, Number::NAN),
side_bearings: (Number::NAN, Number::NAN),
contours: Default::default(),
}
}
}