I'm parsing CFF data. I've gotten up to the point of "Top DICT INDEX" entry. I've successfully parsed version data and "Name INDEX" however I'm struggling with parsing of the next entry "Top DICT INDEX".
According to Adobe technical note #5176 section 8:
This contains the top-level DICTs of all the fonts in the FontSet stored in an INDEX structure.
So I thought it'd be logical to parse this index of dicts just as the Name INDEX except for treating array entries as char arrays I'd parse them as DICT data types. Here's where I got the problem. INDEX data type declares two-byte (Card16) array count in big-endian format. According to the INDEX's meta data I have 257 entries (two bytes with 1 in it (data[offset] << 8) + data[++offset]
). But specification states:
Objects contained within this INDEX correspond to those in the Name INDEX in both order and number.
My Name INDEX contained 1 entry (the name of the actual font). So I'm a bit confused to whether I have off-by-one offset problem somewhere in data parsing or the actual font is invalid?
As it seems - it was off-by-one mistake.