Skip to content

Commit

Permalink
Implement FromObjRef, FromTableRef for CompositeGlyph so fontc can wr…
Browse files Browse the repository at this point in the history
…ite them down and restore them
  • Loading branch information
rsheeter committed Jul 5, 2023
1 parent f01feb1 commit 0f0aef1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions write-fonts/src/tables/glyf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,36 @@ impl<'a> FromObjRef<read::tables::glyf::SimpleGlyph<'a>> for SimpleGlyph {

impl<'a> FromTableRef<read::tables::glyf::SimpleGlyph<'a>> for SimpleGlyph {}

impl<'a> FromObjRef<read::tables::glyf::CompositeGlyph<'a>> for CompositeGlyph {
fn from_obj_ref(from: &read::tables::glyf::CompositeGlyph, _data: read::FontData) -> Self {
let bbox = Bbox {
x_min: from.x_min(),
y_min: from.y_min(),
x_max: from.x_max(),
y_max: from.y_max(),
};
let components = from
.components()
.map(|c| Component {
glyph: c.glyph,
anchor: c.anchor,
flags: c.flags.into(),
transform: c.transform,
})
.collect();
Self {
bbox,
components,
_instructions: from
.instructions()
.map(|v| v.to_owned())
.unwrap_or_default(),
}
}
}

impl<'a> FromTableRef<read::tables::glyf::CompositeGlyph<'a>> for CompositeGlyph {}

/// A little helper for managing how we're representing a given delta
#[derive(Clone, Copy, Debug)]
enum CoordDelta {
Expand Down

0 comments on commit 0f0aef1

Please sign in to comment.