This program checks whether the indexToLocFormat
field in a font with TTF outlines is valid.
This is a tidied-up segment of something else I'm writing and I was testing it with Cascadia Mono, but it kept falling over when reading the loca
[^1] table because as it turns out, the indexToLocFormat
field in the head
[^2] table was wrong. This field determines whether the offsets in the loca
table are 16 bits each (Offset16
) or 32 bits each (Offset32
).[^3] The result was that the following check would fail.
Offsets must be in ascending order, with loca[n] <= loca[n+1]. The length of each glyph description is determined by the difference between two consecutive entries: loca[n+1] - loca[n]. To compute the length of the last glyph description, there is an extra entry in the offsets array after the entry for the last valid glyph ID. Thus, the number of elements in the offsets array is numGlyphs + 1.[^1]
For what it's worth, the checksums were all right and so were all