aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Mendal <mendal@google.com>2014-06-06 03:21:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-06 03:21:12 +0000
commitf9fdb6e2d1e4fd727d4076d2d5d1a07a778c3fb9 (patch)
treec59ee90da13b8d4685ade9810180e896867c61c1
parentcb42068e894d3c06c92070e759a062e2fccb0062 (diff)
parentec5f5150e2c9ba53696fbddae504a004398b367a (diff)
downloadfonttools-f9fdb6e2d1e4fd727d4076d2d5d1a07a778c3fb9.tar.gz
Merge "Simplify cmap subtable format 4 idDelta code"
-rw-r--r--Lib/fontTools/ttLib/tables/_c_m_a_p.py27
1 files changed, 2 insertions, 25 deletions
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index 9dea0108..d0c6c41f 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -694,28 +694,6 @@ class cmap_format_4(CmapSubtable):
getGlyphName = self.ttFont.getGlyphName
names = list(map(getGlyphName, gids ))
list(map(operator.setitem, [cmap]*lenCmap, charCodes, names))
-
-
-
- def setIDDelta(self, idDelta):
- # The lowest gid in glyphIndexArray, after subtracting idDelta, must be 1.
- # idDelta is a short, and must be between -32K and 32K
- # startCode can be between 0 and 64K-1, and the first glyph index can be between 1 and 64K-1
- # This means that we have a problem because we can need to assign to idDelta values
- # between -(64K-2) and 64K -1.
- # Since the final gi is reconstructed from the glyphArray GID by:
- # (short)finalGID = (gid + idDelta) % 0x10000),
- # we can get from a startCode of 0 to a final GID of 64 -1K by subtracting 1, and casting the
- # negative number to an unsigned short.
- # Similarly , we can get from a startCode of 64K-1 to a final GID of 1 by adding 2, because of
- # the modulo arithmetic.
-
- if idDelta > 0x7FFF:
- idDelta = idDelta - 0x10000
- elif idDelta < -0x8000:
- idDelta = idDelta + 0x10000
-
- return idDelta
def compile(self, ttFont):
@@ -787,8 +765,7 @@ class cmap_format_4(CmapSubtable):
for charCode in range(startCode[i], endCode[i] + 1):
indices.append(cmap[charCode])
if (indices == list(range(indices[0], indices[0] + len(indices)))):
- idDeltaTemp = self.setIDDelta(indices[0] - startCode[i])
- idDelta.append( idDeltaTemp)
+ idDelta.append((indices[0] - startCode[i]) % 0x10000)
idRangeOffset.append(0)
else:
# someone *definitely* needs to get killed.
@@ -807,7 +784,7 @@ class cmap_format_4(CmapSubtable):
rangeShift = 2 * segCount - searchRange
charCodeArray = array.array("H", endCode + [0] + startCode)
- idDeltaArray = array.array("h", idDelta)
+ idDeltaArray = array.array("H", idDelta)
restArray = array.array("H", idRangeOffset + glyphIndexArray)
if sys.byteorder != "big":
charCodeArray.byteswap()