Skip to content

Commit

Permalink
Merge pull request #405 from googlefonts/build-gdef
Browse files Browse the repository at this point in the history
Use GDEF table provided by fea-rs
  • Loading branch information
anthrotype authored Aug 20, 2023
2 parents a4ee74c + 5059099 commit e4c8eb0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
14 changes: 11 additions & 3 deletions fontbe/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ impl Work<Context, AnyWorkId, Error> for FeatureWork {
}

fn also_completes(&self) -> Vec<AnyWorkId> {
vec![WorkId::Gpos.into(), WorkId::Gsub.into()]
vec![
WorkId::Gpos.into(),
WorkId::Gsub.into(),
WorkId::Gdef.into(),
]
}

fn exec(&self, context: &Context) -> Result<(), Error> {
Expand All @@ -153,16 +157,20 @@ impl Work<Context, AnyWorkId, Error> 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());
}
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");
}
Expand Down
10 changes: 7 additions & 3 deletions fontbe/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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(),
Expand All @@ -86,6 +88,7 @@ fn bytes_for(context: &Context, id: WorkId) -> Result<Vec<u8>, 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()),
Expand Down Expand Up @@ -114,6 +117,7 @@ impl Work<Context, AnyWorkId, Error> for FontWork {
WorkId::Glyf.into(),
WorkId::Gpos.into(),
WorkId::Gsub.into(),
WorkId::Gdef.into(),
WorkId::Gvar.into(),
WorkId::Loca.into(),
WorkId::Maxp.into(),
Expand Down
10 changes: 7 additions & 3 deletions fontbe/src/orchestration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -60,6 +60,7 @@ pub enum WorkId {
GlyfFragment(GlyphName),
Gpos,
Gsub,
Gdef,
Gvar,
GvarFragment(GlyphName),
Head,
Expand Down Expand Up @@ -375,6 +376,7 @@ pub struct Context {
pub glyf: BeContextItem<Bytes>,
pub gsub: BeContextItem<BeValue<Gsub>>,
pub gpos: BeContextItem<BeValue<Gpos>>,
pub gdef: BeContextItem<BeValue<Gdef>>,
pub gvar: BeContextItem<Bytes>,
pub post: BeContextItem<BeValue<Post>>,
pub loca: BeContextItem<Bytes>,
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions fontbe/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
3 changes: 3 additions & 0 deletions fontc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -615,6 +616,7 @@ mod tests {
BeWorkIdentifier::Font.into(),
BeWorkIdentifier::Gpos.into(),
BeWorkIdentifier::Gsub.into(),
BeWorkIdentifier::Gdef.into(),
],
completed
);
Expand Down Expand Up @@ -727,6 +729,7 @@ mod tests {
BeWorkIdentifier::Font.into(),
BeWorkIdentifier::Gpos.into(),
BeWorkIdentifier::Gsub.into(),
BeWorkIdentifier::Gdef.into(),
],
completed
);
Expand Down

0 comments on commit e4c8eb0

Please sign in to comment.