Skip to content

Commit

Permalink
add repro for duplicate G3 GSMetric with filter attribute #1269
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Feb 14, 2025
1 parent e2adbee commit 92b89b3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
13 changes: 13 additions & 0 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,19 @@ mod tests {
assert_eq!(master.get_metric("italic angle"), None);
}

#[test]
fn v3_duplicate_metrics_first_wins() {
// In this test font, the default master contains two 'x-height' metric values,
// the first (501) that applies globally, and a second one (450) that applies
// only to small-caps, using GSMetric's `filter` attribute which we ignore as
// it is not relevant to build OS/2 and MVAR tables.
// We match glyphsLib and only consider the first metric with a given name.
let font = Font::load(&glyphs3_dir().join("WghtVar_OS2.glyphs")).unwrap();
let master = font.default_master();

assert_eq!(master.get_metric("x-height"), Some((Some(501.), None)));
}

#[test]
fn v2_preserve_custom_alignment_zones() {
let font = Font::load(&glyphs2_dir().join("alignment_zones_v2.glyphs")).unwrap();
Expand Down
12 changes: 11 additions & 1 deletion resources/testdata/glyphs2/WghtVar_OS2.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
.appVersion = "3219";
.appVersion = "3340";
DisplayStrings = (
"-",
"!"
Expand Down Expand Up @@ -94,6 +94,10 @@ value = -290;
{
name = hheaLineGap;
value = 43;
},
{
name = smallCapHeight;
value = 450;
}
);
descender = -42;
Expand All @@ -104,6 +108,12 @@ xHeight = 501;
{
ascender = 800;
capHeight = 700;
customParameters = (
{
name = smallCapHeight;
value = 480;
}
);
descender = -200;
id = "E09E0C54-128D-4FEA-B209-1B70BEFE300B";
weight = Bold;
Expand Down
10 changes: 10 additions & 0 deletions resources/testdata/glyphs3/WghtVar_OS2.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ pos = 702;
},
{
pos = 501;
},
{
pos = 450;
}
);
name = Regular;
Expand All @@ -115,6 +118,9 @@ pos = 700;
},
{
pos = 500;
},
{
pos = 480;
}
);
name = Bold;
Expand Down Expand Up @@ -278,6 +284,10 @@ type = "cap height";
},
{
type = "x-height";
},
{
filter = "case == 3";
type = "x-height";
}
);
properties = (
Expand Down

0 comments on commit 92b89b3

Please sign in to comment.