1
1
mirror of https://github.com/rsms/inter.git synced 2024-11-30 11:26:32 +03:00

display: round all kerning values to integers

This commit is contained in:
Rasmus Andersson 2020-04-08 20:04:59 -07:00
parent f4116ac9ac
commit 9890b2508d
2 changed files with 5055 additions and 5010 deletions

View File

@ -0,0 +1,45 @@
#!/usr/bin/env python
# encoding: utf8
__doc__ = """
Rounds all kerning values in a Glyphs file to integers
"""
import os, sys, re
pat = re.compile(r'(.*=\s*)(\-?\d[\d\.]*);\n')
file = sys.argv[1]
outlines = []
count = 0
with open(file, "r") as f:
print(f)
level = 0
done = False
for lineno, line in enumerate(f):
if not done:
if level == 0:
if line == "kerning = {\n":
print("BEGIN at line", lineno)
level = 1
else:
if line.find("{") != -1:
level += 1
if line.find("}") != -1:
level -= 1
m = pat.match(line)
if m is not None:
val = m.group(2)
val2 = str(int(float(val)))
line = m.group(1) + val2 + ";\n"
if val != val2:
count += 1
if level == 0:
print("END at line", lineno)
done = True
outlines.append(line)
if count == 0:
print("all kerning values in %s are integers (no change)" % file)
else:
print("rounded %r kerning values in %s" % (count, file))
with open(file, "w") as f:
f.write("".join(outlines))

File diff suppressed because it is too large Load Diff