use crate::tables::font_header::FontHeader;
use crate::tables::maximum_profile::MaximumProfile;
use crate::Result;
#[derive(Clone, Debug)]
pub enum GlyphMapping {
HalfOffsets(Vec<u16>),
Offsets(Vec<u32>),
}
impl<'l> crate::walue::Read<'l> for GlyphMapping {
type Parameter = (&'l FontHeader, &'l MaximumProfile);
fn read<T: crate::tape::Read>(
tape: &mut T,
(header, profile): Self::Parameter,
) -> Result<Self> {
let glyph_count = profile.glyph_count();
match header.glyph_mapping_format {
0 => Ok(GlyphMapping::HalfOffsets(tape.take_given(glyph_count + 1)?)),
1 => Ok(GlyphMapping::Offsets(tape.take_given(glyph_count + 1)?)),
_ => raise!("found an unknown format of the glyph-to-location mapping"),
}
}
}