diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-04-20 17:23:48 -0700 |
---|---|---|
committer | jamesgk <jamesgk19@gmail.com> | 2015-04-20 17:28:37 -0700 |
commit | 2c8a3b194e13773a824d13ee48a958761fe085c0 (patch) | |
tree | 86d3f7e0f8eb906146625a951e37a4c9373fb0b4 /scripts/lib/fontbuild/mix.py | |
parent | 4d7c8b8da3b2d69b5dfdef13fcb17736c7f79a88 (diff) |
Re-add dropped anchors to glyphs during build.
This is a temporary workaround until VFB to UFO conversion is fixed.
Diffstat (limited to 'scripts/lib/fontbuild/mix.py')
-rw-r--r-- | scripts/lib/fontbuild/mix.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/scripts/lib/fontbuild/mix.py b/scripts/lib/fontbuild/mix.py index 70d2e3a..cc0a0a8 100644 --- a/scripts/lib/fontbuild/mix.py +++ b/scripts/lib/fontbuild/mix.py @@ -15,6 +15,7 @@ from numpy import array, append import copy +import json from robofab.objects.objectsRF import RPoint from robofab.world import OpenFont from decomposeGlyph import decomposeGlyph @@ -214,12 +215,13 @@ class FGlyph: class Master: - def __init__(self, font=None, v=0, kernlist=None, overlay=None): + def __init__(self, font=None, v=0, kernlist=None, overlay=None, + anchorPath=None): if isinstance(font, FFont): self.font = None self.ffont = font elif isinstance(font,str): - self.openFont(font,overlay) + self.openFont(font,overlay, anchorPath) elif isinstance(font,Mix): self.font = font else: @@ -238,7 +240,7 @@ class Master: and not k[0] == ""] #TODO implement class based kerning / external kerning file - def openFont(self, path, overlayPath=None): + def openFont(self, path, overlayPath=None, anchorPath=None): self.font = OpenFont(path) for g in self.font: size = len(g) @@ -252,6 +254,16 @@ class Master: for overlayGlyph in overlayFont: font.insertGlyph(overlayGlyph) + if anchorPath: + for glyphName, anchors in json.loads(open(anchorPath).read()): + if not self.font.has_key(glyphName): + continue + glyph = self.font[glyphName] + if glyph.anchors: + continue + for name, x, y in anchors: + glyph.appendAnchor(str(name), (x, y)) + self.ffont = FFont(self.font) |