1
1
mirror of https://github.com/rsms/inter.git synced 2025-01-08 09:19:54 +03:00

round kerning to integer values

This commit is contained in:
Rasmus Andersson 2022-06-04 14:31:56 -07:00
parent 4a7ceaf374
commit 30a2594c2f
2 changed files with 19944 additions and 20121 deletions

View File

@ -0,0 +1,33 @@
#MenuTitle: Round Kerning of current master
# encoding: utf-8
import GlyphsApp
__doc__="""
Rounds kerning of the currently selected master to integer values
and drops any kerning smaller than 4.
"""
font = Glyphs.font
master_id = font.selectedFontMaster.id
MIN_VALUE = 4
to_be_removed = [] # [(L,R) ...]
try:
Glyphs.font.disableUpdateInterface()
for left, r_dict in font.kerning[master_id].items():
if not left.startswith('@'):
left = font.glyphForId_(left).name
for right, value in r_dict.items():
if not right.startswith('@'):
right = font.glyphForId_(right).name
value2 = float(int(value)) # floor()
if abs(value2) < MIN_VALUE:
to_be_removed.append((left, right))
elif value2 != value:
font.setKerningForPair(master_id, left, right, value2)
for left, right in to_be_removed:
print("removing pair (%s, %s)" % (left, right))
font.removeKerningForPair(master_id, left, right)
finally:
Glyphs.font.enableUpdateInterface()

File diff suppressed because it is too large Load Diff