Annotate fonts with ruby (pinyin/romaji) and produce modified TTF/WOFF2 outputs.
1use fontcull_skrifa::outline::OutlinePen;
2use kurbo::BezPath;
3
4pub struct PathPen {
5 pub path: BezPath,
6}
7
8impl PathPen {
9 pub fn new() -> Self {
10 Self {
11 path: BezPath::new(),
12 }
13 }
14}
15
16impl OutlinePen for PathPen {
17 fn move_to(&mut self, x: f32, y: f32) {
18 self.path.move_to((x as f64, y as f64));
19 }
20
21 fn line_to(&mut self, x: f32, y: f32) {
22 self.path.line_to((x as f64, y as f64));
23 }
24
25 fn quad_to(&mut self, cx0: f32, cy0: f32, x: f32, y: f32) {
26 self.path
27 .quad_to((cx0 as f64, cy0 as f64), (x as f64, y as f64));
28 }
29
30 fn curve_to(&mut self, cx0: f32, cy0: f32, cx1: f32, cy1: f32, x: f32, y: f32) {
31 self.path.curve_to(
32 (cx0 as f64, cy0 as f64),
33 (cx1 as f64, cy1 as f64),
34 (x as f64, y as f64),
35 );
36 }
37
38 fn close(&mut self) {
39 self.path.close_path();
40 }
41}