Skip to content

Commit

Permalink
[write-fonts] Impl FontRead for glyf types
Browse files Browse the repository at this point in the history
In codegen we impl this trait for any type that impls FromTableRef, but
this was missing for these types (which don't use codegen)
  • Loading branch information
cmyr authored and dfrg committed Aug 2, 2023
1 parent 715e016 commit 3fabc17
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion write-fonts/src/tables/glyf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ use kurbo::{BezPath, Rect};
use read_fonts::{
tables::glyf::{Anchor, CompositeGlyphFlags, CurvePoint, SimpleGlyphFlags, Transform},
types::GlyphId,
FontRead,
};

use crate::{
from_obj::{FromObjRef, FromTableRef},
from_obj::{FromObjRef, FromTableRef, ToOwnedTable},
FontWrite,
};

Expand Down Expand Up @@ -520,6 +521,18 @@ impl<'a> FromObjRef<read_fonts::tables::glyf::CompositeGlyph<'a>> for CompositeG

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

impl<'a> FontRead<'a> for SimpleGlyph {
fn read(data: read_fonts::FontData<'a>) -> Result<Self, read_fonts::ReadError> {
read_fonts::tables::glyf::SimpleGlyph::read(data).map(|g| g.to_owned_table())
}
}

impl<'a> FontRead<'a> for CompositeGlyph {
fn read(data: read_fonts::FontData<'a>) -> Result<Self, read_fonts::ReadError> {
read_fonts::tables::glyf::CompositeGlyph::read(data).map(|g| g.to_owned_table())
}
}

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

0 comments on commit 3fabc17

Please sign in to comment.