diff options
-rw-r--r-- | scripts/build-v2.py | 9 | ||||
-rw-r--r-- | scripts/lib/fontbuild/mix.py | 18 |
2 files changed, 21 insertions, 6 deletions
diff --git a/scripts/build-v2.py b/scripts/build-v2.py index a861a76..61c7cbb 100644 --- a/scripts/build-v2.py +++ b/scripts/build-v2.py @@ -31,9 +31,12 @@ BASEDIR = os.path.abspath( # Masters -rg = Master("%s/src/v2/Roboto_Regular.ufo" % BASEDIR) -bd = Master("%s/src/v2/Roboto_Bold.ufo" % BASEDIR) -th = Master("%s/src/v2/Roboto_Thin.ufo" % BASEDIR) +rg = Master("%s/src/v2/Roboto_Regular.ufo" % BASEDIR, + anchorPath="%s/res/anchors_regular.txt" % BASEDIR) +bd = Master("%s/src/v2/Roboto_Bold.ufo" % BASEDIR, + anchorPath="%s/res/anchors_bold.txt" % BASEDIR) +th = Master("%s/src/v2/Roboto_Thin.ufo" % BASEDIR, + anchorPath="%s/res/anchors_thin.txt" % BASEDIR) # build condensed masters 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) |