mod builder;
pub(crate) 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(),
}
}
}