Skip to content

Commit

Permalink
[CFF2IndexOf] Fix data_base
Browse files Browse the repository at this point in the history
From the spec:
"Offsets in the offset array are relative to the byte
that precedes the object data."
  • Loading branch information
behdad committed Mar 16, 2024
1 parent 4370674 commit 3a4afca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib/fontTools/ttLib/tables/otConverters.py
Expand Up @@ -1859,7 +1859,7 @@ def getReadArray(reader, offSize):
offsets = readArray(count + 1)
items = []
lastOffset = offsets.pop(0)
reader.readData(lastOffset) # In case first offset is not 0
reader.readData(lastOffset - 1) # In case first offset is not 1

for offset in offsets:
assert lastOffset <= offset
Expand All @@ -1880,7 +1880,7 @@ def getReadArray(reader, offSize):
def get_read_item():
reader_copy = reader.copy()
offset_pos = reader.pos
data_pos = offset_pos + (count + 1) * offSize
data_pos = offset_pos + (count + 1) * offSize - 1
readArray = getReadArray(reader_copy, offSize)

def read_item(i):
Expand Down Expand Up @@ -1922,7 +1922,7 @@ def write(self, writer, font, tableDict, values, repeatIndex=None):
]

offsets = [len(item) for item in items]
offsets = [0] + list(accumulate(offsets))
offsets = list(accumulate(offsets, initial=1))

lastOffset = offsets[-1]
offSize = (
Expand Down

0 comments on commit 3a4afca

Please sign in to comment.