read_fonts/tables/glyf/outline/
borrowed.rs1use super::{outline_to_path, PathContourStart};
4use crate::{
5 model::glyph::outline::PathSink,
6 tables::glyf::{PointCoord, PointFlags, PHANTOM_POINT_COUNT},
7 types::Point,
8};
9
10#[derive(Clone, Debug)]
14pub struct OutlineRef<'a, C: PointCoord> {
15 pub(super) points: &'a [Point<C>],
16 pub(super) flags: &'a [PointFlags],
17 pub(super) contours: &'a [u16],
18 pub(super) phantom: [Point<C>; PHANTOM_POINT_COUNT],
19}
20
21impl<C: PointCoord> OutlineRef<'_, C> {
22 pub fn points(&self) -> &[Point<C>] {
24 self.points
25 }
26
27 pub fn flags(&self) -> &[PointFlags] {
29 self.flags
30 }
31
32 pub fn contours(&self) -> &[u16] {
34 self.contours
35 }
36
37 pub fn phantom_points(&self) -> &[Point<C>; PHANTOM_POINT_COUNT] {
39 &self.phantom
40 }
41
42 pub fn adjusted_lsb(&self) -> C {
44 self.phantom[0].x
45 }
46
47 pub fn adjusted_advance_width(&self) -> C {
49 self.phantom[1].x - self.phantom[0].x
50 }
51
52 #[must_use]
60 pub fn to_path(&self, start: PathContourStart, sink: &mut impl PathSink) -> bool {
61 outline_to_path(self.points, self.flags, self.contours, start, sink)
62 }
63}