Skip to content

Commit

Permalink
Merge pull request #1161 from googlefonts/vend
Browse files Browse the repository at this point in the history
Don't overwrite Glyphs v3 values with v2 values
  • Loading branch information
dfrg authored Dec 3, 2024
2 parents c4c6af1 + 2231f61 commit 5736bc9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
11 changes: 11 additions & 0 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ struct RawName {
values: Vec<RawNameValue>,
}

impl RawName {
fn is_empty(&self) -> bool {
self.value.is_none() && self.values.is_empty()
}
}

#[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)]
struct RawNameValue {
language: String,
Expand Down Expand Up @@ -1558,6 +1564,11 @@ impl RawFont {
);

let mut v2_to_v3_param = |v2_name: &str, v3_name: &str| {
if let Some(v3) = properties.iter().find(|n| n.key == v3_name) {
if !v3.is_empty() {
return;
}
}
if let Some(value) = self.custom_parameters.string(v2_name) {
v2_to_v3_name(&mut properties, Some(value), v3_name);
}
Expand Down
7 changes: 7 additions & 0 deletions glyphs2fontir/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1951,4 +1951,11 @@ mod tests {
)
);
}

#[test]
fn prefer_vendorid_in_properties() {
let (_, context) = build_static_metadata(glyphs3_dir().join("MultipleVendorIDs.glyphs"));
let static_metadata = context.static_metadata.get();
assert_eq!(Tag::new(b"RGHT"), static_metadata.misc.vendor_id);
}
}
56 changes: 56 additions & 0 deletions resources/testdata/glyphs3/MultipleVendorIDs.glyphs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
.formatVersion = 3;
axes = (
{
name = Weight;
tag = wght;
}
);
customParameters = (
{
name = vendorID;
value = WRNG;
}
);

familyName = FamilyName;
fontMaster = (
{
axesValues = (
400
);
id = m01;
name = Regular;
},
{
axesValues = (
700
);
id = "E09E0C54-128D-4FEA-B209-1B70BEFE300B";
name = Bold;
}
);
glyphs = (
{
glyphname = space;
layers = (
{
layerId = m01;
width = 200;
},
{
layerId = "E09E0C54-128D-4FEA-B209-1B70BEFE300B";
width = 600;
}
);
unicode = 32;
}
);
properties = (
{
key = vendorID;
value = RGHT;
},
);
unitsPerEm = 1000;
}

0 comments on commit 5736bc9

Please sign in to comment.