Skip to content

Commit

Permalink
Merge pull request #1179 from googlefonts/glyphs-old-style-fea-names-…
Browse files Browse the repository at this point in the history
…but-notempty-ones

[glyphs] Ignore *empty* legacy fea name records
  • Loading branch information
rsheeter authored Dec 5, 2024
2 parents 951eb61 + df3553f commit 1088897
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,11 @@ impl RawFeature {
/// <https://glyphsapp.com/learn/stylistic-sets#g-names-for-stylistic-sets>
fn legacy_name_record_maybe(&self) -> Option<String> {
let name = self.notes.as_deref()?.strip_prefix("Name:")?.trim();
Some(format!("name 3 1 0x409 \"{name}\";"))
if name.is_empty() {
None
} else {
Some(format!("name 3 1 0x409 \"{name}\";"))
}
}

// https://github.com/googlefonts/glyphsLib/blob/24b4d340e4c82948ba121dcfe563c1450a8e69c9/Lib/glyphsLib/builder/features.py#L134
Expand Down Expand Up @@ -3590,10 +3594,15 @@ mod tests {
#[test]
fn parse_legacy_stylistic_set_name() {
let font = Font::load(&glyphs2_dir().join("FeaLegacyName.glyphs")).unwrap();
assert_eq!(font.features.len(), 1);
assert!(font.features[0]
assert_eq!(font.features.len(), 2);
let [ss01, ss02] = font.features.as_slice() else {
panic!("wrong number of features");
};

assert!(ss01
.content
.contains("name 3 1 0x409 \"Alternate placeholder\""));
assert!(!ss02.content.contains("name 3 1"))
}

// <https://github.com/googlefonts/fontc/issues/1175>
Expand Down
6 changes: 6 additions & 0 deletions resources/testdata/glyphs2/FeaLegacyName.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ code = "sub a by a.ss01;";
name = ss01;
notes = "Name: Alternate placeholder";
},
{
automatic = 1;
code = "sub a by a.ss01;";
name = ss02;
notes = "Name: ";
},
);
fontMaster = (
{
Expand Down

0 comments on commit 1088897

Please sign in to comment.