Skip to content

Commit

Permalink
Merge pull request #452 from googlefonts/skip-node-userdata
Browse files Browse the repository at this point in the history
glyphs-reader: ignore nodes userData
  • Loading branch information
anthrotype authored Sep 22, 2023
2 parents 33fb7c0 + 3dc0f4b commit 0ad1c9d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
10 changes: 8 additions & 2 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,17 @@ impl FromPlist for Node {
let x = spl.next().unwrap().parse().unwrap();
let y = spl.next().unwrap().parse().unwrap();
let pt = Point::new(x, y);
let node_type = spl.next().unwrap().parse().unwrap();
let mut raw_node_type = spl.next().unwrap();
// drop the userData dict, we don't use it for compilation
if raw_node_type.contains('{') {
raw_node_type = raw_node_type.split('{').next().unwrap().trim_end();
}
let node_type = raw_node_type.parse().unwrap();
Node { pt, node_type }
}
Plist::Array(value) => {
if value.len() != 3 {
// ignore the fourth element (userData) unused for compilation
if value.len() < 3 {
panic!("Invalid node content {plist:?}");
};
let x = value[0].as_f64().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion resources/testdata/glyphs2/WghtVar.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ paths = (
{
closed = 1;
nodes = (
"131 250 LINE",
"131 250 LINE {name = hr00;}",
"470 250 LINE",
"470 330 LINE",
"131 330 LINE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ paths = (
{
closed = 1;
nodes = (
"131 250 LINE",
"131 250 LINE {name = hr00;}",
"470 250 LINE",
"470 330 LINE",
"131 330 LINE"
Expand Down
4 changes: 3 additions & 1 deletion resources/testdata/glyphs3/WghtVar.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ shapes = (
{
closed = 1;
nodes = (
(131,250,l),
(131,250,l,{
name = hr00;
}),
(470,250,l),
(470,330,l),
(131,330,l)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ shapes = (
{
closed = 1;
nodes = (
(131,250,l),
(131,250,l,{
name = hr00;
}),
(470,250,l),
(470,330,l),
(131,330,l)
Expand Down

0 comments on commit 0ad1c9d

Please sign in to comment.