diff options
Diffstat (limited to 'scripts/lib/fontbuild')
-rw-r--r-- | scripts/lib/fontbuild/Build.py | 5 | ||||
-rw-r--r-- | scripts/lib/fontbuild/anchors.py | 7 | ||||
-rw-r--r-- | scripts/lib/fontbuild/generateGlyph.py | 49 | ||||
-rw-r--r-- | scripts/lib/fontbuild/kerning.py | 2 | ||||
-rw-r--r-- | scripts/lib/fontbuild/mix.py | 14 |
5 files changed, 61 insertions, 16 deletions
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py index b8943f7..490fe45 100644 --- a/scripts/lib/fontbuild/Build.py +++ b/scripts/lib/fontbuild/Build.py @@ -62,6 +62,7 @@ class FontProject: self.predecompose = self.config.get("glyphs","predecompose").split() self.lessItalic = self.config.get("glyphs","lessitalic").split() self.deleteList = self.config.get("glyphs","delete").split() + self.noItalic = self.config.get("glyphs","noitalic").split() self.buildnumber = self.loadBuildNumber() self.buildOTF = False @@ -134,8 +135,10 @@ class FontProject: if g.name in self.lessItalic: italicizeGlyph(f, g, 9, stemWidth=stemWidth) - elif g.name != ".notdef": + elif False == (g.name in self.noItalic): italicizeGlyph(f, g, 10, stemWidth=stemWidth) + #elif g.name != ".notdef": + # italicizeGlyph(g, 10, stemWidth=stemWidth) if g.width != 0: g.width += 10 diff --git a/scripts/lib/fontbuild/anchors.py b/scripts/lib/fontbuild/anchors.py index 622d52a..a617b2f 100644 --- a/scripts/lib/fontbuild/anchors.py +++ b/scripts/lib/fontbuild/anchors.py @@ -27,15 +27,18 @@ 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 anc in g.anchors: + if anc.name == "top": + g.removeAnchor(anc) + break g.appendAnchor("top", (anchor.x + int(dx), anchor.y + int(dy))) - elif "bottom"==anchorName: + elif anchorName in ["bottom", "bottomu"]: anchors = f[accentName].anchors for anchor in anchors: if "mkmkbottom_acc" == anchor.name: diff --git a/scripts/lib/fontbuild/generateGlyph.py b/scripts/lib/fontbuild/generateGlyph.py index c674c38..d7e49d8 100644 --- a/scripts/lib/fontbuild/generateGlyph.py +++ b/scripts/lib/fontbuild/generateGlyph.py @@ -15,7 +15,7 @@ import re from anchors import alignComponentsToAnchors - +from string import find def parseComposite(composite): c = composite.split("=") @@ -33,6 +33,7 @@ def parseComposite(composite): 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: @@ -43,19 +44,55 @@ def copyMarkAnchors(f, g, srcname, width): g.appendAnchor(anchor.name, (anchor.x + width, anchor.y)) if "top" == anchor.name: if g.unicode == None: - continue - if g.unicode > 0x02B0: - continue + 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 parenttop_present: + if 0 == parenttop_present: + g.appendAnchor("parent_top", anchor.position) + + if "bottom" == anchor.name: + if g.unicode == None: continue - g.appendAnchor("parent_top", anchor.position) + 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: + g.appendAnchor("bottom", anchor.position) + +# g.appendAnchor("top", anchor.position) + # if "rhotichook" == anchor.name: # g.appendAnchor(anchor.name, (anchor.x + width, anchor.y)) + + #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: + g.appendAnchor("top", anchor_parent_top.position) def generateGlyph(f,gname,glyphList={}): diff --git a/scripts/lib/fontbuild/kerning.py b/scripts/lib/fontbuild/kerning.py index 302c330..c93e303 100644 --- a/scripts/lib/fontbuild/kerning.py +++ b/scripts/lib/fontbuild/kerning.py @@ -85,7 +85,7 @@ class KernFeatureWriter(AbstractFeatureWriter): else: rulesAdded = 1 self.ruleCount += rulesAdded - if self.ruleCount > 2048: + if self.ruleCount > 1024: lines.append(" subtable;") self.ruleCount = rulesAdded lines.append(" %spos %s %s %d;" % (enum, left, right, val)) diff --git a/scripts/lib/fontbuild/mix.py b/scripts/lib/fontbuild/mix.py index 63f218f..58ef246 100644 --- a/scripts/lib/fontbuild/mix.py +++ b/scripts/lib/fontbuild/mix.py @@ -122,8 +122,8 @@ class FGlyph: g.width = self._derefX(self.width) if len(g.components) == len(self.components): for i in range(len(self.components)): - g.components[i].scale = (self._derefX(self.components[i][0] + 0), - self._derefY(self.components[i][1] + 0)) + g.components[i].scale = (self._derefX(self.components[i][0] + 0, asInt=False), + self._derefY(self.components[i][1] + 0, asInt=False)) g.components[i].offset = (self._derefX(self.components[i][0] + 1), self._derefY(self.components[i][1] + 1)) if len(g.anchors) == len(self.anchors): @@ -202,11 +202,13 @@ class FGlyph: ng.name = self.name return ng - def _derefX(self,id): - return int(round(self.dataX[id])) + def _derefX(self,id, asInt=True): + val = self.dataX[id] + return int(round(val)) if asInt else val - def _derefY(self,id): - return int(round(self.dataY[id])) + def _derefY(self,id, asInt=True): + val = self.dataY[id] + return int(round(val)) if asInt else val def addDiff(self,gB,gC): newGlyph = self + (gB - gC) |