summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-01-14 05:42:32 +0300
committerRasmus Andersson <rasmus@notion.se>2018-01-14 05:42:32 +0300
commit093cc3047cfe7c5a776a6e3c69d07f04ada04888 (patch)
tree45860a466811970ceefd37523fb1f1ca12cc7893
parent64f4aaed31af968decc9ba1ba5d65a0a43d092fe (diff)
downloadinter-093cc3047cfe7c5a776a6e3c69d07f04ada04888.tar.xz
misc/rf-scripts/AdjustWidth.py
-rw-r--r--misc/rf-scripts/AdjustWidth.py39
1 files changed, 29 insertions, 10 deletions
diff --git a/misc/rf-scripts/AdjustWidth.py b/misc/rf-scripts/AdjustWidth.py
index 35168b65a..af0968300 100644
--- a/misc/rf-scripts/AdjustWidth.py
+++ b/misc/rf-scripts/AdjustWidth.py
@@ -10,11 +10,12 @@ if __name__ == "__main__":
print "Resizing glyph margins for %r" % font
# how much to add or remove from each glyph's margin
- A = -8
+ A = 16
if font is not None:
# first, check for errors and collect glyphs we should adjust
glyphs = []
+ glyphNamesToAdjust = set()
ignored = []
errors = 0
@@ -37,6 +38,7 @@ if __name__ == "__main__":
continue
glyphs.append(g)
+ glyphNamesToAdjust.add(g.name)
if errors > 0:
print "Stopping changes because there are errors"
@@ -47,28 +49,45 @@ if __name__ == "__main__":
print '# name => [ (prevLeftMargin, prevRightMargin), (newLeft, newRight) ]'
print 'resized_glyphs = ['
+ adjustments = dict()
+
+ onlyGlyphs = None # ['A', 'Lambda'] # DEBUG
+ count = 0
+
for g in glyphs:
+ if onlyGlyphs is not None:
+ if not g.name in onlyGlyphs:
+ continue
+ if len(onlyGlyphs) == count:
+ break
+ count += 1
+
+ for comp in g.components:
+ # adjust offset of any components which are being adjusted
+ if comp.baseGlyph in glyphNamesToAdjust:
+ # x, y -- counter-balance x offset
+ comp.offset = (comp.offset[0] - A, comp.offset[1])
+
newLeftMargin = int(g.leftMargin + A)
newRightMargin = int(g.rightMargin + A)
print ' "%s": [(%g, %g), (%g, %g)],' % (
g.name, g.leftMargin, g.rightMargin, newLeftMargin, newRightMargin)
- # order of assignment is probably important
- g.rightMargin = int(newRightMargin)
g.leftMargin = int(newLeftMargin)
+ g.rightMargin = int(newRightMargin)
print '] # resized_glyphs'
font.update()
- if len(ignored) > 0:
- print ''
- print '# name => [what, reason]'
- print "ignored_glyphs = ["
- for t in ignored:
- print ' "%s": ["ignore", %r],' % t
- print '] # ignored_glyphs'
+ # if len(ignored) > 0:
+ # print ''
+ # print '# name => [what, reason]'
+ # print "ignored_glyphs = ["
+ # for t in ignored:
+ # print ' "%s": ["ignore", %r],' % t
+ # print '] # ignored_glyphs'
else:
print "No fonts open"