From 5059099e23063cb1c0996fb21cad01615f113aae Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Thu, 17 Aug 2023 15:59:34 -0400 Subject: [PATCH] Use GDEF table provided by fea-rs --- fontbe/src/features.rs | 14 +++++++++++--- fontbe/src/font.rs | 10 +++++++--- fontbe/src/orchestration.rs | 10 +++++++--- fontbe/src/paths.rs | 1 + fontc/src/lib.rs | 3 +++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/fontbe/src/features.rs b/fontbe/src/features.rs index f94b576c..36421dd1 100644 --- a/fontbe/src/features.rs +++ b/fontbe/src/features.rs @@ -129,7 +129,11 @@ impl Work for FeatureWork { } fn also_completes(&self) -> Vec { - vec![WorkId::Gpos.into(), WorkId::Gsub.into()] + vec![ + WorkId::Gpos.into(), + WorkId::Gsub.into(), + WorkId::Gdef.into(), + ] } fn exec(&self, context: &Context) -> Result<(), Error> { @@ -153,9 +157,10 @@ impl Work for FeatureWork { let result = result?; debug!( - "Built features, gpos? {} gsub? {}", + "Built features, gpos? {} gsub? {} gdef? {}", result.gpos.is_some(), - result.gsub.is_some() + result.gsub.is_some(), + result.gdef.is_some(), ); if let Some(gpos) = result.gpos { context.gpos.set_unconditionally(gpos.into()); @@ -163,6 +168,9 @@ impl Work for FeatureWork { if let Some(gsub) = result.gsub { context.gsub.set_unconditionally(gsub.into()); } + if let Some(gdef) = result.gdef { + context.gdef.set_unconditionally(gdef.into()); + } } else { debug!("No fea file, dull compile"); } diff --git a/fontbe/src/font.rs b/fontbe/src/font.rs index 2d85ee77..0c3465cb 100644 --- a/fontbe/src/font.rs +++ b/fontbe/src/font.rs @@ -7,9 +7,9 @@ use fontir::orchestration::WorkId as FeWorkId; use log::debug; use read_fonts::{ tables::{ - avar::Avar, cmap::Cmap, fvar::Fvar, glyf::Glyf, gpos::Gpos, gsub::Gsub, gvar::Gvar, - head::Head, hhea::Hhea, hmtx::Hmtx, loca::Loca, maxp::Maxp, name::Name, os2::Os2, - post::Post, stat::Stat, + avar::Avar, cmap::Cmap, fvar::Fvar, gdef::Gdef, glyf::Glyf, gpos::Gpos, gsub::Gsub, + gvar::Gvar, head::Head, hhea::Hhea, hmtx::Hmtx, loca::Loca, maxp::Maxp, name::Name, + os2::Os2, post::Post, stat::Stat, }, types::Tag, TopLevelTable, @@ -43,6 +43,7 @@ const TABLES_TO_MERGE: &[(WorkId, Tag, TableType)] = &[ (WorkId::Glyf, Glyf::TAG, TableType::Static), (WorkId::Gpos, Gpos::TAG, TableType::Static), (WorkId::Gsub, Gsub::TAG, TableType::Static), + (WorkId::Gdef, Gdef::TAG, TableType::Static), (WorkId::Gvar, Gvar::TAG, TableType::Variable), (WorkId::Loca, Loca::TAG, TableType::Static), (WorkId::Maxp, Maxp::TAG, TableType::Static), @@ -63,6 +64,7 @@ fn has(context: &Context, id: WorkId) -> bool { WorkId::Glyf => context.glyf.try_get().is_some(), WorkId::Gpos => context.gpos.try_get().is_some(), WorkId::Gsub => context.gsub.try_get().is_some(), + WorkId::Gdef => context.gdef.try_get().is_some(), WorkId::Gvar => context.gvar.try_get().is_some(), WorkId::Loca => context.loca.try_get().is_some(), WorkId::Maxp => context.maxp.try_get().is_some(), @@ -86,6 +88,7 @@ fn bytes_for(context: &Context, id: WorkId) -> Result, Error> { WorkId::Glyf => context.glyf.get().as_ref().get().to_vec(), WorkId::Gpos => to_bytes(context.gpos.get().as_ref()), WorkId::Gsub => to_bytes(context.gsub.get().as_ref()), + WorkId::Gdef => to_bytes(context.gdef.get().as_ref()), WorkId::Gvar => context.gvar.get().as_ref().get().to_vec(), WorkId::Loca => context.loca.get().as_ref().get().to_vec(), WorkId::Maxp => to_bytes(context.maxp.get().as_ref()), @@ -114,6 +117,7 @@ impl Work for FontWork { WorkId::Glyf.into(), WorkId::Gpos.into(), WorkId::Gsub.into(), + WorkId::Gdef.into(), WorkId::Gvar.into(), WorkId::Loca.into(), WorkId::Maxp.into(), diff --git a/fontbe/src/orchestration.rs b/fontbe/src/orchestration.rs index d978956a..b7250934 100644 --- a/fontbe/src/orchestration.rs +++ b/fontbe/src/orchestration.rs @@ -27,9 +27,9 @@ use serde::{Deserialize, Serialize}; use write_fonts::{ dump_table, tables::{ - avar::Avar, cmap::Cmap, fvar::Fvar, glyf::Glyph as RawGlyph, gpos::Gpos, gsub::Gsub, - gvar::GlyphDeltas, head::Head, hhea::Hhea, loca::LocaFormat, maxp::Maxp, name::Name, - os2::Os2, post::Post, stat::Stat, variations::Tuple, + avar::Avar, cmap::Cmap, fvar::Fvar, gdef::Gdef, glyf::Glyph as RawGlyph, gpos::Gpos, + gsub::Gsub, gvar::GlyphDeltas, head::Head, hhea::Hhea, loca::LocaFormat, maxp::Maxp, + name::Name, os2::Os2, post::Post, stat::Stat, variations::Tuple, }, validate::Validate, FontWrite, OtRound, @@ -60,6 +60,7 @@ pub enum WorkId { GlyfFragment(GlyphName), Gpos, Gsub, + Gdef, Gvar, GvarFragment(GlyphName), Head, @@ -375,6 +376,7 @@ pub struct Context { pub glyf: BeContextItem, pub gsub: BeContextItem>, pub gpos: BeContextItem>, + pub gdef: BeContextItem>, pub gvar: BeContextItem, pub post: BeContextItem>, pub loca: BeContextItem, @@ -404,6 +406,7 @@ impl Context { glyf: self.glyf.clone_with_acl(acl.clone()), gsub: self.gsub.clone_with_acl(acl.clone()), gpos: self.gpos.clone_with_acl(acl.clone()), + gdef: self.gdef.clone_with_acl(acl.clone()), gvar: self.gvar.clone_with_acl(acl.clone()), post: self.post.clone_with_acl(acl.clone()), loca: self.loca.clone_with_acl(acl.clone()), @@ -437,6 +440,7 @@ impl Context { glyf: ContextItem::new(WorkId::Glyf.into(), acl.clone(), persistent_storage.clone()), gpos: ContextItem::new(WorkId::Gpos.into(), acl.clone(), persistent_storage.clone()), gsub: ContextItem::new(WorkId::Gsub.into(), acl.clone(), persistent_storage.clone()), + gdef: ContextItem::new(WorkId::Gdef.into(), acl.clone(), persistent_storage.clone()), gvar: ContextItem::new(WorkId::Gvar.into(), acl.clone(), persistent_storage.clone()), post: ContextItem::new(WorkId::Post.into(), acl.clone(), persistent_storage.clone()), loca: ContextItem::new(WorkId::Loca.into(), acl.clone(), persistent_storage.clone()), diff --git a/fontbe/src/paths.rs b/fontbe/src/paths.rs index 2a8694a1..93d90bab 100644 --- a/fontbe/src/paths.rs +++ b/fontbe/src/paths.rs @@ -54,6 +54,7 @@ impl Paths { WorkId::Glyf => self.build_dir.join("glyf.table"), WorkId::Gsub => self.build_dir.join("gsub.table"), WorkId::Gpos => self.build_dir.join("gpos.table"), + WorkId::Gdef => self.build_dir.join("gdef.table"), WorkId::Gvar => self.build_dir.join("gvar.table"), WorkId::Loca => self.build_dir.join("loca.table"), WorkId::LocaFormat => self.build_dir.join("loca.format"), diff --git a/fontc/src/lib.rs b/fontc/src/lib.rs index 7c82a4e2..73310b8f 100644 --- a/fontc/src/lib.rs +++ b/fontc/src/lib.rs @@ -524,6 +524,7 @@ mod tests { BeWorkIdentifier::GlyfFragment("plus".into()).into(), BeWorkIdentifier::Gpos.into(), BeWorkIdentifier::Gsub.into(), + BeWorkIdentifier::Gdef.into(), BeWorkIdentifier::Gvar.into(), BeWorkIdentifier::GvarFragment("bar".into()).into(), BeWorkIdentifier::GvarFragment("plus".into()).into(), @@ -615,6 +616,7 @@ mod tests { BeWorkIdentifier::Font.into(), BeWorkIdentifier::Gpos.into(), BeWorkIdentifier::Gsub.into(), + BeWorkIdentifier::Gdef.into(), ], completed ); @@ -727,6 +729,7 @@ mod tests { BeWorkIdentifier::Font.into(), BeWorkIdentifier::Gpos.into(), BeWorkIdentifier::Gsub.into(), + BeWorkIdentifier::Gdef.into(), ], completed );