From b1e176898d6ae69587ca3ac204cc07ae5ee51ef3 Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Wed, 2 Aug 2023 11:41:28 -0400 Subject: [PATCH] [write-fonts] Impl FontRead for glyf types In codegen we impl this trait for any type that impls FromTableRef, but this was missing for these types (which don't use codegen) --- write-fonts/src/tables/glyf.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/write-fonts/src/tables/glyf.rs b/write-fonts/src/tables/glyf.rs index 389509d95..3a0dd68dd 100644 --- a/write-fonts/src/tables/glyf.rs +++ b/write-fonts/src/tables/glyf.rs @@ -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, }; @@ -520,6 +521,18 @@ impl<'a> FromObjRef> for CompositeG impl<'a> FromTableRef> for CompositeGlyph {} +impl<'a> FontRead<'a> for SimpleGlyph { + fn read(data: read_fonts::FontData<'a>) -> Result { + 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 { + 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 {