-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery-glyphdata.py
More file actions
executable file
·41 lines (33 loc) · 1.08 KB
/
query-glyphdata.py
File metadata and controls
executable file
·41 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
from fontParts.world import *
import csv
import sys
# Open UFO and glyph_data CSV
ufo = sys.argv[1]
font = OpenFont(ufo)
csv_file = open(sys.argv[2])
gd = csv.DictReader(csv_file)
# Compare glyph names in UFO and CSV file
## Read glyph names from UFO
ufo_glyph_list = set()
for glyph in font:
glyph_name = glyph.name
if glyph_name in ufo_glyph_list:
print(f'error: {glyph_name} is duplicated in UFO')
ufo_glyph_list.add(glyph_name)
## Read glyph names from CSV file
gd_glyph_list = set()
for row in gd:
glyph_name = row['glyph_name']
if glyph_name in gd_glyph_list:
print(f'error: {glyph_name} is duplicated in glyph_data.csv')
gd_glyph_list.add(glyph_name)
## Show differences
length = len(gd_glyph_list)
print(f'error: missing from glyph_data.csv which has {length} glyphs')
for glyph_name in ufo_glyph_list - gd_glyph_list:
print(f'{glyph_name}')
length = len(ufo_glyph_list)
print(f'warning: missing from UFO glyph list which has {length} glyphs')
for glyph_name in gd_glyph_list - ufo_glyph_list:
print(f'{glyph_name}')