-
Notifications
You must be signed in to change notification settings - Fork 0
/
query-interpolation.py
executable file
·51 lines (41 loc) · 1.27 KB
/
query-interpolation.py
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
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
from fontParts.world import *
import sys
def collect(filename):
font = OpenFont(filename)
inventory = set()
cmap = set()
for glyph in font:
inventory.add(glyph.name)
if glyph.unicode is not None:
cmap.add(glyph.unicode)
return font, inventory, cmap
# Open UFOs
font1, inventory1, cmap1 = collect(sys.argv[1])
font2, inventory2, cmap2 = collect(sys.argv[2])
## Are the glyph inventories the same
print('glyphs only in font 1')
for glyph_name in sorted(inventory1 - inventory2):
print(glyph_name)
print('glyphs only in font 2')
for glyph_name in sorted(inventory2 - inventory1):
print(glyph_name)
## Are the codepoints the same
print('codepoints only in font 1')
for codepoint in sorted(cmap1 - cmap2):
print(f'{codepoint:04X}')
print('codepoints only in font 2')
for codepoint in sorted(cmap2 - cmap1):
print(f'{codepoint:04X}')
## Are glyphs compatible for interpolation
for glyph_name in inventory1 & inventory2:
glyph1 = font1[glyph_name]
glyph2 = font2[glyph_name]
compatible, report = glyph1.isCompatible(glyph2)
if not compatible:
print(f'glyph {glyph_name} is not compatible for interpolation\n{str(report)}')
# Modify UFO
# Save UFO
# font.changed()
# font.save()
# font.close()