Bug fixes

This commit is contained in:
Martin Hosken 2017-09-14 16:47:01 +07:00 committed by Sascha Brawer
parent 1d164cc9c0
commit 84ce740814
2 changed files with 16 additions and 7 deletions

View File

@ -25,9 +25,14 @@ class table_F__e_a_t(DefaultTable.DefaultTable):
allfeats = [] allfeats = []
maxsetting = 0 maxsetting = 0
for i in range(numFeats): for i in range(numFeats):
(fid, nums, _, offset, flags, lid) = struct.unpack(">LHHLHH", if self.version >= 2.0:
(fid, nums, _, offset, flags, lid) = struct.unpack(">LHHLHH",
data[16*i:16*(i+1)]) data[16*i:16*(i+1)])
offset = int((offset - 12 - 16 * numFeats) / 4) offset = int((offset - 12 - 16 * numFeats) / 4)
else:
(fid, nums, offset, flags, lid) = struct.unpack(">HHLHH",
data[12*i:12*(i+1)])
offset = int((offset - 12 - 12 * numFeats) / 4)
allfeats.append((fid, nums, offset, flags, lid)) allfeats.append((fid, nums, offset, flags, lid))
maxsetting = max(maxsetting, offset + nums) maxsetting = max(maxsetting, offset + nums)
data = data[16*numFeats:] data = data[16*numFeats:]
@ -53,8 +58,12 @@ class table_F__e_a_t(DefaultTable.DefaultTable):
vdat = "" vdat = ""
offset = 0 offset = 0
for f, v in sorted(self.features.items()): for f, v in sorted(self.features.items()):
fdat += struct.pack(">LHHLHH", grUtils.tag2num(f), len(v.settings), if self.version >= 2.0:
0, offset * 4 + 12 + 16 * len(self.features), v.flags, v.label) fdat += struct.pack(">LHHLHH", grUtils.tag2num(f), len(v.settings),
0, offset * 4 + 12 + 16 * len(self.features), v.flags, v.label)
else:
fdat += struct.pack(">HHLHH", grUtils.tag2num(f), len(v.settings),
offset * 4 + 12 + 12 * len(self.features), v.flags, v.label)
for s, l in sorted(v.settings.items()): for s, l in sorted(v.settings.items()):
vdat += struct.pack(">HH", s, l) vdat += struct.pack(">HH", s, l)
offset += len(v.settings) offset += len(v.settings)

View File

@ -165,7 +165,7 @@ aCode_info = (
("PUSH_GLYPH_ATTR_OBS", "Bb"), ("PUSH_GLYPH_ATTR_OBS", "Bb"),
("PUSH_GLYPH_METRIC", "Bbb"), ("PUSH_GLYPH_METRIC", "Bbb"),
("PUSH_FEAT", "Bb"), ("PUSH_FEAT", "Bb"),
("PUSH_ATT_TO_GATTR_OBS", "Bbb"), ("PUSH_ATT_TO_GATTR_OBS", "Bb"),
("PUSH_ATT_TO_GLYPH_METRIC", "Bbb"), ("PUSH_ATT_TO_GLYPH_METRIC", "Bbb"),
("PUSH_ISLOT_ATTR", "Bbb"), ("PUSH_ISLOT_ATTR", "Bbb"),
("PUSH_IGLYPH_ATTR", "Bbb"), ("PUSH_IGLYPH_ATTR", "Bbb"),
@ -726,12 +726,12 @@ class Pass(object):
for i in range(len(oConstraints)-1,0,-1): for i in range(len(oConstraints)-1,0,-1):
if oConstraints[i] == 0 : if oConstraints[i] == 0 :
oConstraints[i] = oConstraints[i+1] oConstraints[i] = oConstraints[i+1]
self.ruleConstraints = [data[s:e] for (s,e) in izip(oConstraints, oConstraints[1:])] self.ruleConstraints = [(data[s:e] if (e-s > 1) else "") for (s,e) in izip(oConstraints, oConstraints[1:])]
data = data[oConstraints[-1]:] data = data[oConstraints[-1]:]
for i in range(len(oActions)-1,0,-1): for i in range(len(oActions)-1,0,-1):
if oActions[i] == 0: if oActions[i] == 0:
oActions[i] = oActions[i+1] oActions[i] = oActions[i+1]
self.actions = [data[s:e] for (s,e) in izip(oActions, oActions[1:])] self.actions = [(data[s:e] if (e-s > 1) else "") for (s,e) in izip(oActions, oActions[1:])]
data = data[oActions[-1]:] data = data[oActions[-1]:]
# not using debug # not using debug