summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/anchors.py
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-04-08 16:14:56 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:33 -0700
commit56ad4064e8eeff6c320952daef8767188ae7fa63 (patch)
tree5907c6682cb65a0c2ad778605376e95ba8dc436b /scripts/lib/fontbuild/anchors.py
parent40f2f9fdaa46d1773ebc805150da70c9acfeac3e (diff)
Update scripts based on 03/31 delivery.
Diffstat (limited to 'scripts/lib/fontbuild/anchors.py')
-rw-r--r--scripts/lib/fontbuild/anchors.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/lib/fontbuild/anchors.py b/scripts/lib/fontbuild/anchors.py
index d82ffa7..fe3e280 100644
--- a/scripts/lib/fontbuild/anchors.py
+++ b/scripts/lib/fontbuild/anchors.py
@@ -13,6 +13,37 @@ def getAnchorByName(g,anchorName):
return a
+def moveMarkAnchors(f, g, anchorName, accentName, dx, dy):
+ if "top"==anchorName:
+ anchors = f[accentName].anchors
+ for anchor in anchors:
+ if "mkmktop_acc" == anchor.name:
+ anchor2 = Anchor()
+ #print anchor.x, dx, anchor.y, dy
+ anchor2.name = "top"
+ anchor2.x = anchor.x + int(dx)
+ anchor2.y = anchor.y + int(dy)
+ g.anchors.append(anchor2)
+
+ elif "bottom"==anchorName:
+ anchors = f[accentName].anchors
+ for anchor in anchors:
+ if "mkmkbottom_acc" == anchor.name:
+ for n in range(len(g.anchors)):
+ if g.anchors[n].name == "bottom":
+ del g.anchors[n]
+ break
+ anchor2 = Anchor()
+ #print anchor.x, dx, anchor.y, dy
+ anchor2.name = "bottom"
+ anchor2.x = anchor.x + int(dx)
+ anchor2.y = anchor.y + int(dy)
+ for anc in anchors:
+ if "top" == anc.name:
+ anchor2.x = anc.x + int(dx)
+ g.anchors.append(anchor2)
+
+
def alignComponentToAnchor(f,glyphName,baseName,accentName,anchorName):
g = getGlyph(glyphName,f)
base = getGlyph(baseName,f)
@@ -26,6 +57,8 @@ def alignComponentToAnchor(f,glyphName,baseName,accentName,anchorName):
offset = (a1.x - a2.x, a1.y - a2.y)
c = getComponentByName(f, g, accentName)
c.offset = offset
+ moveMarkAnchors(f, g, anchorName, accentName, offset.x, offset.y)
+
def alignComponentsToAnchors(f,glyphName,baseName,accentNames):
for a in accentNames: