diff options
author | James Godfrey-Kittle <jamesgk@google.com> | 2015-05-11 09:26:40 -0700 |
---|---|---|
committer | James Godfrey-Kittle <jamesgk19@gmail.com> | 2015-05-11 09:26:40 -0700 |
commit | 51a104941b097a959c5d806d567115d99051fcc1 (patch) | |
tree | 9250adb3ddaf15a0bfff3d3fad0bfb4d5a1ff74f | |
parent | d2ac8019271ecd84b6a4ee36056d59ff2f3fcb18 (diff) | |
parent | 05d020abc4a8d5c11b449f738b95c4190998d111 (diff) |
Merge pull request #34 from google/anchor-fix
Fix bug causing inaccurate anchor coordinates.
-rw-r--r-- | res/anchors_bold.json | 282 | ||||
-rw-r--r-- | res/anchors_regular.json | 282 | ||||
-rw-r--r-- | res/anchors_thin.json | 280 | ||||
-rw-r--r-- | scripts/lib/fontbuild/anchors.py | 6 | ||||
-rw-r--r-- | scripts/lib/fontbuild/generateGlyph.py | 18 | ||||
-rw-r--r-- | scripts/lib/fontbuild/mix.py | 15 |
6 files changed, 710 insertions, 173 deletions
diff --git a/res/anchors_bold.json b/res/anchors_bold.json index b8f8956..939d59d 100644 --- a/res/anchors_bold.json +++ b/res/anchors_bold.json @@ -13,20 +13,6 @@ 1600 ] }, - "Gbar": { - "bottom": [ - 726, - 0 - ], - "top": [ - 705, - 1600 - ], - "top0315": [ - 1466, - 1600 - ] - }, "Ibar": { "bottom": [ 381, @@ -114,14 +100,14 @@ 681, -10 ], - "cross": [ - 339, - 1302 - ], "markbottom": [ 681, -10 ], + "parenthesses.w2": [ + 384, + 1302 + ], "top": [ 676, 1600 @@ -193,28 +179,6 @@ 1290 ] }, - "gbar_uni1ABE": { - "bottom": [ - 741, - -487 - ], - "cross": [ - 783, - -128 - ], - "markbottom": [ - 741, - -487 - ], - "top": [ - 741, - 1290 - ], - "top0315": [ - 1534, - 1290 - ] - }, "gcursive": { "bottom": [ 554, @@ -348,7 +312,7 @@ 420, 0 ], - "cross": [ + "parenthesses.w2": [ 426, 842 ], @@ -835,22 +799,182 @@ 1269 ] }, - "uni04BA": { - "left": [ - 989, - 0 - ], - "right": [ - 1313, - 0 + "uni048A": { + "top": [ + 708, + 1914 ], + "top0315": [ + 1424, + 1600 + ] + }, + "uni048B": { "top": [ - 580, + 584, + 1604 + ], + "top0315": [ + 1153, + 1290 + ] + }, + "uni0496": { + "top0315": [ + 2107, + 1600 + ] + }, + "uni0497": { + "top0315": [ + 1816, + 1290 + ] + }, + "uni049B": { + "top0315": [ + 1168, + 1290 + ] + }, + "uni04A2": { + "bottom_dd": [ + 1442, + -407 + ], + "top0315": [ + 1442, + 1600 + ], + "top_dd": [ + 1442, + 1600 + ] + }, + "uni04A3": { + "top0315": [ + 1153, + 1269 + ] + }, + "uni04B2": { + "bottom_dd": [ + 1306, + -407 + ], + "top0315": [ + 1306, 1612 ], + "top_dd": [ + 1306, + 1600 + ] + }, + "uni04B3": { + "bottom_dd": [ + 1051, + -407 + ], + "top0315": [ + 1051, + 1280 + ], + "top_dd": [ + 1051, + 1600 + ] + }, + "uni04B6": { + "top0315": [ + 1429, + 1600 + ] + }, + "uni04B7": { + "top0315": [ + 1140, + 1290 + ] + }, + "uni04C6": { + "top0315": [ + 1155, + 1269 + ] + }, + "uni04C9": { + "bottom_dd": [ + 1442, + -407 + ], "top0315": [ - 1444, + 1442, + 1600 + ], + "top_dd": [ + 1442, + 1600 + ] + }, + "uni04CA": { + "top0315": [ + 1153, + 1269 + ] + }, + "uni04CD": { + "bottom_dd": [ + 1795, + -407 + ], + "top0315": [ + 1795, + 1600 + ], + "top_dd": [ + 1795, + 1600 + ] + }, + "uni04CE": { + "top0315": [ + 1567, + 1269 + ] + }, + "uni04FC": { + "bottom_dd": [ + 1306, + -407 + ], + "top0315": [ + 1306, 1612 + ], + "top_dd": [ + 1306, + 1600 + ] + }, + "uni04FD": { + "bottom_dd": [ + 1051, + -407 + ], + "top0315": [ + 1051, + 1280 + ], + "top_dd": [ + 1051, + 1600 + ] + }, + "uni0513": { + "top0315": [ + 1155, + 1269 ] }, "uni1AB4": { @@ -1088,5 +1212,61 @@ 474, 1182 ] + }, + "uni2C67": { + "bottom_dd": [ + 1442, + -407 + ], + "top0315": [ + 1442, + 1600 + ], + "top_dd": [ + 1442, + 1600 + ] + }, + "uni2C68": { + "bottom_dd": [ + 1153, + -407 + ], + "top0315": [ + 1153, + 1693 + ], + "top_dd": [ + 1153, + 1600 + ] + }, + "uniA790": { + "bottom_dd": [ + 1441, + -407 + ], + "top0315": [ + 1441, + 1600 + ], + "top_dd": [ + 1441, + 1600 + ] + }, + "uniA791": { + "bottom_dd": [ + 1153, + -407 + ], + "top0315": [ + 1153, + 1290 + ], + "top_dd": [ + 1153, + 1600 + ] } }
\ No newline at end of file diff --git a/res/anchors_regular.json b/res/anchors_regular.json index f98241f..e2d015f 100644 --- a/res/anchors_regular.json +++ b/res/anchors_regular.json @@ -13,20 +13,6 @@ 1612 ] }, - "Gbar": { - "bottom": [ - 668, - -10 - ], - "top": [ - 668, - 1633 - ], - "top0315": [ - 1394, - 1633 - ] - }, "Ibar": { "bottom": [ 341, @@ -114,14 +100,14 @@ 600, -10 ], - "cross": [ - 428, - 1303 - ], "markbottom": [ 600, -10 ], + "parenthesses.w2": [ + 352, + 1303 + ], "top": [ 640, 1611 @@ -193,28 +179,6 @@ 1290 ] }, - "gbar_uni1ABE": { - "bottom": [ - 616, - -487 - ], - "cross": [ - 618, - -114 - ], - "markbottom": [ - 616, - -487 - ], - "top": [ - 617, - 1290 - ], - "top0315": [ - 1329, - 1290 - ] - }, "gcursive": { "bottom": [ 555, @@ -348,7 +312,7 @@ 361, 0 ], - "cross": [ + "parenthesses.w2": [ 361, 768 ], @@ -835,22 +799,182 @@ 1249 ] }, - "uni04BA": { - "left": [ - 1031, - 0 - ], - "right": [ - 1231, - 0 + "uni048A": { + "top": [ + 733, + 1896 ], + "top0315": [ + 1462, + 1612 + ] + }, + "uni048B": { "top": [ - 688, + 594, + 1553 + ], + "top0315": [ + 1189, + 1269 + ] + }, + "uni0496": { + "top0315": [ + 1872, 1612 + ] + }, + "uni0497": { + "top0315": [ + 1568, + 1269 + ] + }, + "uni049B": { + "top0315": [ + 1117, + 1268 + ] + }, + "uni04A2": { + "bottom_dd": [ + 1463, + -407 + ], + "top0315": [ + 1463, + 1612 + ], + "top_dd": [ + 1463, + 1600 + ] + }, + "uni04A3": { + "top0315": [ + 1188, + 1269 + ] + }, + "uni04B2": { + "bottom_dd": [ + 1291, + -407 ], "top0315": [ - 1399, + 1291, 1612 + ], + "top_dd": [ + 1291, + 1600 + ] + }, + "uni04B3": { + "bottom_dd": [ + 1020, + -407 + ], + "top0315": [ + 1020, + 1280 + ], + "top_dd": [ + 1020, + 1600 + ] + }, + "uni04B6": { + "top0315": [ + 1411, + 1612 + ] + }, + "uni04B7": { + "top0315": [ + 1119, + 1269 + ] + }, + "uni04C6": { + "top0315": [ + 1191, + 1269 + ] + }, + "uni04C9": { + "bottom_dd": [ + 1463, + -407 + ], + "top0315": [ + 1463, + 1612 + ], + "top_dd": [ + 1463, + 1600 + ] + }, + "uni04CA": { + "top0315": [ + 1188, + 1269 + ] + }, + "uni04CD": { + "bottom_dd": [ + 1792, + -407 + ], + "top0315": [ + 1792, + 1600 + ], + "top_dd": [ + 1792, + 1600 + ] + }, + "uni04CE": { + "top0315": [ + 1524, + 1269 + ] + }, + "uni04FC": { + "bottom_dd": [ + 1291, + -407 + ], + "top0315": [ + 1291, + 1612 + ], + "top_dd": [ + 1291, + 1600 + ] + }, + "uni04FD": { + "bottom_dd": [ + 1020, + -407 + ], + "top0315": [ + 1020, + 1280 + ], + "top_dd": [ + 1020, + 1600 + ] + }, + "uni0513": { + "top0315": [ + 1191, + 1269 ] }, "uni1AB4": { @@ -1088,5 +1212,61 @@ 354, 1182 ] + }, + "uni2C67": { + "bottom_dd": [ + 1463, + -407 + ], + "top0315": [ + 1463, + 1612 + ], + "top_dd": [ + 1463, + 1600 + ] + }, + "uni2C68": { + "bottom_dd": [ + 1129, + -407 + ], + "top0315": [ + 1129, + 1611 + ], + "top_dd": [ + 1129, + 1600 + ] + }, + "uniA790": { + "bottom_dd": [ + 1462, + -407 + ], + "top0315": [ + 1462, + 1600 + ], + "top_dd": [ + 1462, + 1600 + ] + }, + "uniA791": { + "bottom_dd": [ + 1132, + -407 + ], + "top0315": [ + 1132, + 1290 + ], + "top_dd": [ + 1132, + 1600 + ] } }
\ No newline at end of file diff --git a/res/anchors_thin.json b/res/anchors_thin.json index ca4b92f..22242ad 100644 --- a/res/anchors_thin.json +++ b/res/anchors_thin.json @@ -13,20 +13,6 @@ 1612 ] }, - "Gbar": { - "bottom": [ - 729, - 0 - ], - "top": [ - 703, - 1633 - ], - "top0315": [ - 1406, - 1633 - ] - }, "Ibar": { "bottom": [ 314, @@ -114,14 +100,14 @@ 584, -10 ], - "cross": [ - 208, - 1306 - ], "markbottom": [ 584, -10 ], + "parenthesses.w2": [ + 342, + 1306 + ], "top": [ 577, 1612 @@ -193,28 +179,6 @@ 1290 ] }, - "gbar_uni1ABE": { - "bottom": [ - 632, - -447 - ], - "cross": [ - 632, - -134 - ], - "markbottom": [ - 632, - -447 - ], - "top": [ - 645, - 1290 - ], - "top0315": [ - 1311, - 1290 - ] - }, "gcursive": { "bottom": [ 567, @@ -348,7 +312,7 @@ 364, 0 ], - "cross": [ + "parenthesses.w2": [ 363, 800 ], @@ -835,24 +799,184 @@ 1249 ] }, - "uni04BA": { - "left": [ - 1075, - 0 - ], - "right": [ - 1129, - 0 + "uni048A": { + "top": [ + 736, + 1838 ], + "top0315": [ + 1449, + 1612 + ] + }, + "uni048B": { "top": [ - 227, + 555, + 1495 + ], + "top0315": [ + 1121, + 1269 + ] + }, + "uni0496": { + "top0315": [ + 1745, 1612 + ] + }, + "uni0497": { + "top0315": [ + 1574, + 1269 + ] + }, + "uni049B": { + "top0315": [ + 1016, + 1268 + ] + }, + "uni04A2": { + "bottom_dd": [ + 1438, + -407 ], "top0315": [ + 1438, + 1612 + ], + "top_dd": [ + 1438, + 1600 + ] + }, + "uni04A3": { + "top0315": [ + 1121, + 1269 + ] + }, + "uni04B2": { + "bottom_dd": [ + 1223, + -407 + ], + "top0315": [ + 1223, + 1612 + ], + "top_dd": [ + 1223, + 1600 + ] + }, + "uni04B3": { + "bottom_dd": [ + 978, + -407 + ], + "top0315": [ + 978, + 1280 + ], + "top_dd": [ + 978, + 1600 + ] + }, + "uni04B6": { + "top0315": [ 1325, 1612 ] }, + "uni04B7": { + "top0315": [ + 1067, + 1269 + ] + }, + "uni04C6": { + "top0315": [ + 1122, + 1269 + ] + }, + "uni04C9": { + "bottom_dd": [ + 1438, + -407 + ], + "top0315": [ + 1438, + 1612 + ], + "top_dd": [ + 1438, + 1600 + ] + }, + "uni04CA": { + "top0315": [ + 1121, + 1269 + ] + }, + "uni04CD": { + "bottom_dd": [ + 1756, + -407 + ], + "top0315": [ + 1756, + 1612 + ], + "top_dd": [ + 1756, + 1600 + ] + }, + "uni04CE": { + "top0315": [ + 1476, + 1269 + ] + }, + "uni04FC": { + "bottom_dd": [ + 1223, + -407 + ], + "top0315": [ + 1223, + 1612 + ], + "top_dd": [ + 1223, + 1600 + ] + }, + "uni04FD": { + "bottom_dd": [ + 978, + -407 + ], + "top0315": [ + 978, + 1280 + ], + "top_dd": [ + 978, + 1600 + ] + }, + "uni0513": { + "top0315": [ + 1122, + 1269 + ] + }, "uni1AB4": { "_marktop": [ -562, @@ -1088,5 +1212,61 @@ 353, 1263 ] + }, + "uni2C67": { + "bottom_dd": [ + 1438, + -407 + ], + "top0315": [ + 1438, + 1612 + ], + "top_dd": [ + 1438, + 1600 + ] + }, + "uni2C68": { + "bottom_dd": [ + 1121, + -407 + ], + "top0315": [ + 1121, + 1611 + ], + "top_dd": [ + 1121, + 1600 + ] + }, + "uniA790": { + "bottom_dd": [ + 1449, + -407 + ], + "top0315": [ + 1449, + 1612 + ], + "top_dd": [ + 1449, + 1600 + ] + }, + "uniA791": { + "bottom_dd": [ + 1121, + -407 + ], + "top0315": [ + 1121, + 1290 + ], + "top_dd": [ + 1121, + 1600 + ] } }
\ No newline at end of file diff --git a/scripts/lib/fontbuild/anchors.py b/scripts/lib/fontbuild/anchors.py index 9b8095d..622d52a 100644 --- a/scripts/lib/fontbuild/anchors.py +++ b/scripts/lib/fontbuild/anchors.py @@ -39,9 +39,9 @@ def moveMarkAnchors(f, g, anchorName, accentName, dx, dy): anchors = f[accentName].anchors for anchor in anchors: if "mkmkbottom_acc" == anchor.name: - for anchor in g.anchors: - if anchor.name == "bottom": - g.removeAnchor(anchor) + for anc in g.anchors: + if anc.name == "bottom": + g.removeAnchor(anc) break x = anchor.x + int(dx) for anc in anchors: diff --git a/scripts/lib/fontbuild/generateGlyph.py b/scripts/lib/fontbuild/generateGlyph.py index ccfeef1..c674c38 100644 --- a/scripts/lib/fontbuild/generateGlyph.py +++ b/scripts/lib/fontbuild/generateGlyph.py @@ -13,6 +13,7 @@ # limitations under the License. +import re from anchors import alignComponentsToAnchors @@ -65,6 +66,7 @@ def generateGlyph(f,gname,glyphList={}): for componentName in baseName.split("_"): g.appendComponent(componentName, (g.width, 0)) g.width += f[componentName].width + setUnicodeValue(g, glyphList) else: if not f.has_key(glyphName): @@ -75,16 +77,24 @@ def generateGlyph(f,gname,glyphList={}): "anchor not found in glyph '%s'" % (gname, e, baseName)) return g = f[glyphName] + setUnicodeValue(g, glyphList) copyMarkAnchors(f, g, baseName, offset[1] + offset[0]) if offset[0] != 0 or offset[1] != 0: g.width += offset[1] + offset[0] - g.move((offset[0], 0)) + g.move((offset[0], 0), anchors=False) if len(accentNames) > 0: alignComponentsToAnchors(f, glyphName, baseName, accentNames) else: print ("Existing glyph '%s' found in font, ignoring composition " "rule '%s'" % (glyphName, gname)) - # try to ensure every glyph has a unicode value -- used by FDK to make OTFs - if glyphName in glyphList: - f[glyphName].unicode = int(glyphList[glyphName], 16) + +def setUnicodeValue(glyph, glyphList): + """Try to ensure glyph has a unicode value -- used by FDK to make OTFs.""" + + if glyph.name in glyphList: + glyph.unicode = int(glyphList[glyph.name], 16) + else: + uvNameMatch = re.match("uni([\dA-F]{4})$", glyph.name) + if uvNameMatch: + glyph.unicode = int(uvNameMatch.group(1), 16) diff --git a/scripts/lib/fontbuild/mix.py b/scripts/lib/fontbuild/mix.py index bd396ed..7123213 100644 --- a/scripts/lib/fontbuild/mix.py +++ b/scripts/lib/fontbuild/mix.py @@ -260,20 +260,7 @@ class Master: if anchorPath: anchorData = json.load(open(anchorPath)) for glyphName, anchors in anchorData.items(): - - # another bug: some entire glyphs are dropped during conversion. - # example: gbar_uni1ABE - try: - glyph = self.font[glyphName] - except KeyError: - continue - - # another bug: some glyphs are decomposed during conversion, in - # which case they unexpectedly don't drop anchors. - # examples: uni04BA, Gbar (partially decomposed) - if glyph.anchors: - continue - + glyph = self.font[glyphName] for name, (x, y) in anchors.items(): glyph.appendAnchor(str(name), (x, y)) |