summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/generateGlyph.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/fontbuild/generateGlyph.py')
-rw-r--r--scripts/lib/fontbuild/generateGlyph.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/scripts/lib/fontbuild/generateGlyph.py b/scripts/lib/fontbuild/generateGlyph.py
index f2214f0..2b29ada 100644
--- a/scripts/lib/fontbuild/generateGlyph.py
+++ b/scripts/lib/fontbuild/generateGlyph.py
@@ -1,5 +1,5 @@
from anchors import alignComponentsToAnchors
-from FL import *
+
def parseComposite(composite):
c = composite.split("=")
@@ -15,34 +15,33 @@ def parseComposite(composite):
accentNames = [i.split(":") for i in accents ]
return (glyphName, baseName, accentNames, offset)
-def shiftGlyphMembers(g, x):
- g.Shift(Point(x,0))
- for c in g.components:
- c.deltas[0].x = c.deltas[0].x + x
def generateGlyph(f,gname):
if gname.find("_") != -1:
+
+ #TODO(jamesgk@google.com) handle underscores
+ return
+
generateString = gname
- g = f.GenerateGlyph(generateString)
+ g = f.generateGlyph(generateString)
if f.FindGlyph(g.name) == -1:
f.glyphs.append(g)
return g
else:
glyphName, baseName, accentNames, offset = parseComposite(gname)
- components = [baseName] + [i[0] for i in accentNames]
- if len(components) == 1:
- components.append("NONE")
- generateString = "%s=%s" %("+".join(components), glyphName)
- g = f.GenerateGlyph(generateString)
- if f.FindGlyph(g.name) == -1:
- f.glyphs.append(g)
- g1 = f.glyphs[f.FindGlyph(g.name)]
+ if not f.has_key(glyphName):
+ try:
+ f.compileGlyph(glyphName, baseName, accentNames)
+ except KeyError as e:
+ print ("KeyError raised for composition rule '%s', likely %s "
+ "anchor not found in glyph '%s'" % (gname, e, baseName))
+ return
+ g = f[glyphName]
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])
- return g
-
-# generateGlyph(fl.font,"A+ogonek=Aogonek")
-# fl.UpdateFont() \ No newline at end of file
+ alignComponentsToAnchors(f, glyphName, baseName, accentNames)
+ if offset[0] != 0 or offset[1] != 0:
+ g.width += offset[1] + offset[0]
+ g.move((offset[0], 0))
+ else:
+ print ("Existing glyph '%s' found in font, ignoring composition "
+ "rule '%s'" % (glyphName, gname))