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

[layout-normalizer] skip if GPOS not present #630

Merged
merged 1 commit into from
Dec 6, 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
9 changes: 5 additions & 4 deletions layout-normalizer/src/gpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use write_fonts::read::{
},
layout::{DeviceOrVariationIndex, LookupFlag},
},
types::{GlyphId, Tag},
types::GlyphId,
FontData, FontRef, ReadError, TableProvider,
};

Expand All @@ -27,9 +27,10 @@ use crate::{

pub(crate) fn print(f: &mut dyn io::Write, font: &FontRef, names: &NameMap) -> Result<(), Error> {
writeln!(f, "# GPOS #")?;
let table = font
.gpos()
.map_err(|_| Error::MissingTable(Tag::new(b"GPOS")))?;
let Some(table) = font.gpos().ok() else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think you can match so w/o .ok()?
Nit2: Arguably we should fail on any error except there is no GPOS table whereas we are assuming here the only error possible is missing. That's a problem before and after so I wouldn't block on it.

// no GPOS table, nothing to do
return Ok(());
};
let gdef = font.gdef().ok();
let var_store = gdef
.as_ref()
Expand Down