Skip to content

Commit

Permalink
Merge pull request #1279 from googlefonts/tidy
Browse files Browse the repository at this point in the history
Tidy glyphs files a touch
  • Loading branch information
rsheeter authored Feb 14, 2025
2 parents 50917d5 + cdcc86a commit 2fe4a1c
Show file tree
Hide file tree
Showing 91 changed files with 49 additions and 446 deletions.
2 changes: 0 additions & 2 deletions glyphs-reader/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ pub enum Shape {
#[derive(Default, Debug, PartialEq, FromPlist)]
#[allow(non_snake_case)]
struct RawFont {
#[fromplist(key = ".appVersion")]
app_version: i64,
#[fromplist(key = ".formatVersion")]
format_version: i64,
units_per_em: Option<i64>,
Expand Down
49 changes: 49 additions & 0 deletions resources/scripts/tidy_glyphs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Removes elements from .glyphs files that we don't care about.
"""

from pathlib import Path
import re


_EXEMPTIONS = {
("Dated.glyphs", "date"),
}

_DELETE_ME = {
".appVersion",
"DisplayStrings"
"date"
"lastChange"
}


def delete_key(plist_file: Path, plist: str, key: str) -> str:
if (plist_file.name, key) in _EXEMPTIONS:
print("skip", plist_file, key)
return plist
return re.sub(f"(?sm)^{key} = .*?;\n", "", plist)


def main():
testdata_dir = Path(__file__).parent.parent / "testdata"
assert testdata_dir.is_dir(), testdata_dir

plist_files = set()
for subdir in ("glyphs2", "glyphs3"):
for pat in ("*.glyphs", "*.plist"):
plist_files.update((testdata_dir / subdir).rglob(pat))

assert len(plist_files) > 0

for plist_file in plist_files:
plist = plist_file.read_text()

for key in _DELETE_ME:
plist = delete_key(plist_file, plist, key)

plist_file.write_text(plist)


if __name__ == "__main__":
main()
6 changes: 0 additions & 6 deletions resources/testdata/glyphs2/BadIndexing.glyphs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
.appVersion = "3148";
DisplayStrings = (
"-",
"!"
);
customParameters = (
{
name = "Variable Font Origin";
Expand All @@ -23,7 +18,6 @@ Tag = wdth;
);
}
);
date = "2022-12-01 04:52:20 +0000";
familyName = WghtVar;
fontMaster = (
{
Expand Down
12 changes: 0 additions & 12 deletions resources/testdata/glyphs2/Component.glyphs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
.appVersion = "3151";
DisplayStrings = (
".",
","
);
date = "2023-01-20 20:20:30 +0000";
familyName = "New Font";
fontMaster = (
{
Expand All @@ -26,7 +20,6 @@ xHeight = 500;
glyphs = (
{
glyphname = period;
lastChange = "2023-01-20 20:20:51 +0000";
layers = (
{
layerId = m01;
Expand All @@ -48,7 +41,6 @@ unicode = 002E;
},
{
glyphname = comma;
lastChange = "2023-01-20 20:22:39 +0000";
layers = (
{
components = (
Expand All @@ -65,7 +57,6 @@ unicode = 002C;
},
{
glyphname = non_uniform_scale;
lastChange = "2023-01-20 20:22:39 +0000";
layers = (
{
components = (
Expand All @@ -82,7 +73,6 @@ unicode = 0030;
},
{
glyphname = simple_transform;
lastChange = "2023-01-20 20:22:39 +0000";
layers = (
{
components = (
Expand All @@ -99,7 +89,6 @@ unicode = 0031;
},
{
glyphname = simple_transform_again;
lastChange = "2023-01-20 20:22:39 +0000";
layers = (
{
components = (
Expand All @@ -120,7 +109,6 @@ unicode = 0032;
},
{
glyphname = translate_only;
lastChange = "2023-01-20 20:22:39 +0000";
layers = (
{
components = (
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/FeaLegacyName.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3148";
familyName = "legacy stylistic set names";
features = (
{
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/Fea_Class.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3148";
classes = (
{
automatic = 1;
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/Fea_Feature.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3148";
customParameters = (
{
name = Axes;
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/Fea_Order.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3148";
customParameters = (
{
name = Axes;
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/Fea_Prefix.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3148";
customParameters = (
{
name = Axes;
Expand Down
6 changes: 0 additions & 6 deletions resources/testdata/glyphs2/IntermediateLayer.glyphs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
.appVersion = "3300";
DisplayStrings = (
I,
ii
);
customParameters = (
{
name = "Disable Last Change";
Expand Down Expand Up @@ -62,7 +57,6 @@ Tag = wght;
);
}
);
date = "2023-07-20 13:49:39 +0000";
familyName = "Intermediate Layer";
fontMaster = (
{
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/KernImplicitAxes.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ xHeight = 500;
glyphs = (
{
glyphname = hyphen;
lastChange = "2023-06-05 23:23:03 +0000";
layers = (
{
layerId = m01;
Expand Down
3 changes: 0 additions & 3 deletions resources/testdata/glyphs2/MVAR.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3228";
customParameters = (
{
name = "Variable Font Origin";
Expand All @@ -15,7 +14,6 @@ Tag = slnt;
);
}
);
date = "2023-12-05 15:07:25 +0000";
familyName = "MVAR Test";
fontMaster = (
{
Expand Down Expand Up @@ -296,7 +294,6 @@ xHeight = 505;
glyphs = (
{
glyphname = space;
lastChange = "2023-12-07 13:14:38 +0000";
layers = (
{
layerId = m01;
Expand Down
2 changes: 0 additions & 2 deletions resources/testdata/glyphs2/MasterNames-Italic.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3323";
customParameters = (
{
name = "Disable Last Change";
Expand All @@ -19,7 +18,6 @@ Tag = wght;
);
}
);
date = "2024-10-08 16:36:05 +0000";
familyName = "Master Names";
fontMaster = (
{
Expand Down
2 changes: 0 additions & 2 deletions resources/testdata/glyphs2/MasterNames.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3323";
customParameters = (
{
name = "Disable Last Change";
Expand Down Expand Up @@ -27,7 +26,6 @@ Tag = slnt;
);
}
);
date = "2024-10-08 14:26:05 +0000";
familyName = "Master Names";
fontMaster = (
{
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/MatrixComponent.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3219";
familyName = MatrixComponent;
fontMaster = (
{
Expand Down
1 change: 0 additions & 1 deletion resources/testdata/glyphs2/MixedContourComponent.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3151";
familyName = "New Font";
fontMaster = (
{
Expand Down
8 changes: 0 additions & 8 deletions resources/testdata/glyphs2/OpszWghtVar_AxisMappings.glyphs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
.appVersion = "3148";
DisplayStrings = (
"-",
"!"
);
customParameters = (
{
name = Axes;
Expand Down Expand Up @@ -41,7 +36,6 @@ wght = {
};
}
);
date = "2022-12-01 04:52:20 +0000";
familyName = WghtVar;
fontMaster = (
{
Expand Down Expand Up @@ -104,7 +98,6 @@ xHeight = 500;
glyphs = (
{
glyphname = space;
lastChange = "2022-12-01 04:58:12 +0000";
layers = (
{
layerId = thin-12pt;
Expand Down Expand Up @@ -135,7 +128,6 @@ unicode = 0020;
},
{
glyphname = hyphen;
lastChange = "2022-12-01 04:57:39 +0000";
layers = (
{
layerId = thin-12pt;
Expand Down
6 changes: 0 additions & 6 deletions resources/testdata/glyphs2/QCurve.glyphs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
.appVersion = "3208";
DisplayStrings = (
"",
i
);
customParameters = (
{
name = "Disable Last Change";
value = 1;
}
);
date = "2023-07-20 13:49:39 +0000";
familyName = "New Font";
fontMaster = (
{
Expand Down
4 changes: 0 additions & 4 deletions resources/testdata/glyphs2/SlantedFont.glyphs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
.appVersion = "3227";
customParameters = (
{
name = "Variable Font Origin";
Expand All @@ -15,7 +14,6 @@ Tag = slnt;
);
}
);
date = "2023-12-05 14:28:33 +0000";
familyName = "Slanted Font";
fontMaster = (
{
Expand Down Expand Up @@ -54,7 +52,6 @@ xHeight = 500;
glyphs = (
{
glyphname = I;
lastChange = "2023-12-05 14:31:49 +0000";
layers = (
{
layerId = "E09E0C54-128D-4FEA-B209-1B70BEFE300B";
Expand Down Expand Up @@ -91,7 +88,6 @@ unicode = 0049;
},
{
glyphname = space;
lastChange = "2023-12-05 14:44:13 +0000";
layers = (
{
layerId = "E09E0C54-128D-4FEA-B209-1B70BEFE300B";
Expand Down
10 changes: 0 additions & 10 deletions resources/testdata/glyphs2/TheBestNames.glyphs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
.appVersion = "3151";
DisplayStrings = (
"-",
"!"
);
copyright = "Copy!";
customParameters = (
{
Expand Down Expand Up @@ -64,7 +59,6 @@ Tag = wght;
);
}
);
date = "2022-12-01 04:52:20 +0000";
designer = "Designed by me!";
designerURL = "https://example.com/designer";
familyName = FamilyName;
Expand Down Expand Up @@ -95,7 +89,6 @@ xHeight = 500;
glyphs = (
{
glyphname = space;
lastChange = "2022-12-01 04:58:12 +0000";
layers = (
{
layerId = m01;
Expand All @@ -110,7 +103,6 @@ unicode = 0020;
},
{
glyphname = exclam;
lastChange = "2022-12-01 05:10:49 +0000";
layers = (
{
layerId = m01;
Expand Down Expand Up @@ -165,7 +157,6 @@ unicode = 0021;
},
{
glyphname = hyphen;
lastChange = "2022-12-01 04:57:39 +0000";
layers = (
{
layerId = m01;
Expand Down Expand Up @@ -202,7 +193,6 @@ unicode = 002D;
},
{
glyphname = "manual-component";
lastChange = "2022-12-01 04:57:39 +0000";
layers = (
{
components = (
Expand Down
Loading

0 comments on commit 2fe4a1c

Please sign in to comment.