1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Compute the loca table endOffset, of the "first" glyph, correctly (issue 14618)

When there are *multiple* empty glyphs at the start of the data, ensure that the "first" glyph gets a correct `endOffset` to avoid skipping it during parsing in the `sanitizeGlyph` function.
This commit is contained in:
Jonas Jenwald 2022-03-03 14:14:22 +01:00
parent 234aa9a50e
commit 1a7921dbf0
4 changed files with 21 additions and 0 deletions

View file

@ -1980,6 +1980,20 @@ class Font {
locaEntries.sort((a, b) => {
return a.index - b.index;
});
// Calculate the endOffset of the "first" glyph correctly when there are
// *multiple* empty ones at the start of the data (fixes issue14618.pdf).
for (i = 0; i < numGlyphs; i++) {
const { offset, endOffset } = locaEntries[i];
if (offset !== 0 || endOffset !== 0) {
break;
}
const nextOffset = locaEntries[i + 1].offset;
if (nextOffset === 0) {
continue;
}
locaEntries[i].endOffset = nextOffset;
break;
}
const missingGlyphs = Object.create(null);
let writeOffset = 0;