Skip to content

Commit

Permalink
[glyphs2fontir] Don’t panic for unknown language label
Browse files Browse the repository at this point in the history
Warn and skip instead.
  • Loading branch information
khaledhosny committed Oct 9, 2024
1 parent e5bb5c5 commit 202ad73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1969,16 +1969,18 @@ impl RawFeature {
let labels = self
.labels
.iter()
.map(|label| {
let language_id = GLYPHS_TO_OPENTYPE_LANGUAGE_ID
.filter_map(|label| {
GLYPHS_TO_OPENTYPE_LANGUAGE_ID
.iter()
.find(|entry| entry.0 == label.language)
.map(|entry| entry.1)
.unwrap_or_else(|| {
panic!("Unknown feature label language: {}", label.language);
});
let name = label.value.replace("\\", "\\005c").replace("\"", "\\0022");
format!(" name 3 1 0x{:04X} \"{}\";", language_id, name)
.map(|entry| {
let name = label.value.replace("\\", "\\005c").replace("\"", "\\0022");
format!(" name 3 1 0x{:04X} \"{}\";", entry.1, name)
})
.or_else(|| {
warn!("Unknown feature label language: {}", label.language);
None
})
})
.collect::<Vec<_>>()
.join("\n");
Expand Down
4 changes: 4 additions & 0 deletions resources/testdata/glyphs3/Fea_Labels.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ value = "Test 1";
{
language = ARA;
value = "اختبار ١";
},
{
language = SKIPME;
value = "Skip me";
}
);
tag = ss01;
Expand Down

0 comments on commit 202ad73

Please sign in to comment.