diff --git a/src/core/fonts.js b/src/core/fonts.js index f249e229b..1a7a58089 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3262,6 +3262,13 @@ var Font = (function FontClosure() { }; } var locaData = loca.data; + var locaDataSize = itemSize * (1 + numGlyphs); + // is loca.data too short or long? + if (locaData.length !== locaDataSize) { + locaData = new Uint8Array(locaDataSize); + locaData.set(loca.data.subarray(0, locaDataSize)); + loca.data = locaData; + } // removing the invalid glyphs var oldGlyfData = glyf.data; var oldGlyfDataLength = oldGlyfData.length; @@ -3305,9 +3312,7 @@ var Font = (function FontClosure() { glyf.data.set(newGlyfData.subarray(0, writeOffset)); } glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset); - loca.data = new Uint8Array(locaData.length + itemSize); - loca.data.set(locaData); - itemEncode(loca.data, locaData.length, + itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength); } else { glyf.data = newGlyfData.subarray(0, writeOffset); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index c330cd14a..ec7cb1773 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -39,6 +39,7 @@ !S2.pdf !helloworld-bad.pdf !zerowidthline.pdf +!bug868745.pdf !issue1002.pdf !issue925.pdf !gradientfill.pdf diff --git a/test/pdfs/bug868745.pdf b/test/pdfs/bug868745.pdf new file mode 100644 index 000000000..b92db20cc Binary files /dev/null and b/test/pdfs/bug868745.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index f6d672911..71de3b33a 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -189,6 +189,12 @@ "rounds": 1, "type": "load" }, + { "id": "bug868745", + "file": "pdfs/bug868745.pdf", + "md5": "86111ea5097dd7daffcdea891ad1b348", + "rounds": 1, + "type": "load" + }, { "id": "thuluthfont-pdf", "file": "pdfs/ThuluthFeatures.pdf", "md5": "b7e18bf7a3d6a9c82aefa12d721072fc",