Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[write-fonts] Impl FontRead for glyf types #555

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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