summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/anchors.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/fontbuild/anchors.py')
-rw-r--r--scripts/lib/fontbuild/anchors.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/lib/fontbuild/anchors.py b/scripts/lib/fontbuild/anchors.py
index 7cc3869..08d2d41 100644
--- a/scripts/lib/fontbuild/anchors.py
+++ b/scripts/lib/fontbuild/anchors.py
@@ -20,6 +20,40 @@ def getAnchorByName(g,anchorName):
if a.name == 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:
+ for i in range(len(g.anchors)):
+ if g.anchors[i].name == "top":
+ del g.anchors[i]
+ break
+ 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 anchorName in ["bottom", "bottomu"]:
+ 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)
@@ -35,6 +69,8 @@ def alignComponentToAnchor(f,glyphName,baseName,accentName,anchorName):
c = getComponentByName(f,g,accentName)
c.deltas[0].x = offset.x
c.deltas[0].y = offset.y
+ moveMarkAnchors(f, g, anchorName, accentName, offset.x, offset.y)
+
def alignComponentsToAnchors(f,glyphName,baseName,accentNames):
for a in accentNames: