From f0446ecc7eee2fe55e4f81563e035f8bee01b748 Mon Sep 17 00:00:00 2001 From: James Godfrey-Kittle Date: Wed, 17 Jun 2015 11:25:49 -0700 Subject: Script updates from Paratype 15/06/16. --- scripts/lib/fontbuild/generateGlyph.py | 87 +++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) (limited to 'scripts/lib/fontbuild/generateGlyph.py') diff --git a/scripts/lib/fontbuild/generateGlyph.py b/scripts/lib/fontbuild/generateGlyph.py index f2214f0..7bb8ca2 100644 --- a/scripts/lib/fontbuild/generateGlyph.py +++ b/scripts/lib/fontbuild/generateGlyph.py @@ -1,5 +1,6 @@ from anchors import alignComponentsToAnchors from FL import * +from string import find def parseComposite(composite): c = composite.split("=") @@ -20,6 +21,87 @@ def shiftGlyphMembers(g, x): for c in g.components: c.deltas[0].x = c.deltas[0].x + x +def copyMarkAnchors(f, g, srcname, width): + unicode_range = range(0x0030, 0x02B0) + range(0x1E00, 0x1EFF) + anchors = f[srcname].anchors + for anchor in anchors: + if "top_dd" == anchor.name: + anchor1 = Anchor(anchor) + anchor1.x += width + g.anchors.append(anchor1) + if "bottom_dd" == anchor.name: + anchor1 = Anchor(anchor) + anchor1.x += width + g.anchors.append(anchor1) + if "top0315" == anchor.name: + anchor1 = Anchor(anchor) + anchor1.x += width + g.anchors.append(anchor1) + if "top" == anchor.name: + if g.unicode == None: + if -1 == find(g.name, ".ccmp"): + continue + if False == (g.unicode in unicode_range): + if -1 == find(g.name, ".ccmp"): + continue + #if g.unicode > 0x02B0: + # continue + parenttop_present = 0 + for anc in g.anchors: + if anc.name == "parent_top": + parenttop_present = 1 + if 0 == parenttop_present: + anchor2 = Anchor(anchor) + anchor2.name = "parent_top" +# anchor1.x += width + g.anchors.append(anchor2) + + if "bottom" == anchor.name: + if g.unicode == None: + continue + if False == (g.unicode in unicode_range): + continue + #if g.unicode > 0x02B0: + # continue + bottom_present = 0 + for anc in g.anchors: + if anc.name == "bottom": + bottom_present = 1 + if 0 == bottom_present: + anchor2 = Anchor(anchor) + anchor2.name = "bottom" +# anchor1.x += width + g.anchors.append(anchor2) + + +# anchor1 = Anchor(anchor) +# anchor1.name = "top" +# anchor1.x += width +# g.anchors.append(anchor1) + + # if "rhotichook" == anchor.name: + # anchor1 = Anchor(anchor) + # anchor1.x += width + # g.anchors.append(anchor1) + + #print g.anchors + for anchor in g.anchors: + if "top" == anchor.name: + #print g.name, g.anchors + return + + anchor_parent_top = None + + for anchor in g.anchors: + if "parent_top" == anchor.name: + anchor_parent_top = anchor + break + + if anchor_parent_top: + anchor_top = Anchor(anchor_parent_top) + anchor_top.name = "top" + g.anchors.append(anchor_top) + def generateGlyph(f,gname): if gname.find("_") != -1: generateString = gname @@ -34,14 +116,15 @@ def generateGlyph(f,gname): components.append("NONE") generateString = "%s=%s" %("+".join(components), glyphName) g = f.GenerateGlyph(generateString) + copyMarkAnchors(f, g, baseName, offset[1] + offset[0]) if f.FindGlyph(g.name) == -1: f.glyphs.append(g) g1 = f.glyphs[f.FindGlyph(g.name)] - if len(accentNames) > 0: - alignComponentsToAnchors(f,glyphName,baseName,accentNames) if (offset[0] != 0 or offset[1] != 0): g1.width += offset[1] + offset[0] shiftGlyphMembers(g1,offset[0]) + if len(accentNames) > 0: + alignComponentsToAnchors(f,glyphName,baseName,accentNames) return g # generateGlyph(fl.font,"A+ogonek=Aogonek") -- cgit v1.2.3