diff --git a/src/core/fonts.js b/src/core/fonts.js index e6055ae8e..f8b6ad740 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 60b824a17..83f6f8a9d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -321,6 +321,7 @@ !jbig2_symbol_offset.pdf !gradientfill.pdf !bug903856.pdf +!issue14618.pdf !bug850854.pdf !issue12810.pdf !bug866395.pdf diff --git a/test/pdfs/issue14618.pdf b/test/pdfs/issue14618.pdf new file mode 100644 index 000000000..9e4f8972f Binary files /dev/null and b/test/pdfs/issue14618.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 43230fd1c..e3cdf1fec 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -351,6 +351,12 @@ "rounds": 1, "type": "load" }, + { "id": "issue14618", + "file": "pdfs/issue14618.pdf", + "md5": "8a4a5aac59519228019aaffdfbd56f17", + "rounds": 1, + "type": "eq" + }, { "id": "intelisa-eq", "file": "pdfs/intelisa.pdf", "md5": "24643ebe348a568cfe6a532055c71493",