pub type NormalizedCoord = read_fonts::types::F2Dot14;
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]
pub struct Size(f32);
impl Size {
pub fn new(ppem: f32) -> Self {
Self(ppem)
}
pub fn unscaled() -> Self {
Self(0.0)
}
pub fn ppem(self) -> Option<f32> {
(self.0 > 0.0).then_some(self.0)
}
pub fn linear_scale(self, units_per_em: u16) -> f32 {
if self.0 > 0.0 && units_per_em != 0 {
self.0 / units_per_em as f32
} else {
1.0
}
}
}
#[derive(Copy, Clone, Default, Debug)]
pub struct LocationRef<'a>(&'a [NormalizedCoord]);
impl<'a> LocationRef<'a> {
pub fn new(coords: &'a [NormalizedCoord]) -> Self {
Self(coords)
}
pub fn coords(&self) -> &'a [NormalizedCoord] {
self.0
}
}
impl<'a> From<&'a [NormalizedCoord]> for LocationRef<'a> {
fn from(value: &'a [NormalizedCoord]) -> Self {
Self(value)
}
}
impl<'a> IntoIterator for LocationRef<'a> {
type IntoIter = core::slice::Iter<'a, NormalizedCoord>;
type Item = &'a NormalizedCoord;
fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}
impl<'a> IntoIterator for &'_ LocationRef<'a> {
type IntoIter = core::slice::Iter<'a, NormalizedCoord>;
type Item = &'a NormalizedCoord;
fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}