Resizes loca table when needed

This commit is contained in:
Yury Delendik 2013-11-02 18:56:48 -05:00
parent 768a86d59d
commit 175341cb0d
4 changed files with 15 additions and 3 deletions

View File

@ -3262,6 +3262,13 @@ var Font = (function FontClosure() {
}; };
} }
var locaData = loca.data; 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 // removing the invalid glyphs
var oldGlyfData = glyf.data; var oldGlyfData = glyf.data;
var oldGlyfDataLength = oldGlyfData.length; 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, writeOffset));
} }
glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset); glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
loca.data = new Uint8Array(locaData.length + itemSize); itemEncode(loca.data, locaData.length - itemSize,
loca.data.set(locaData);
itemEncode(loca.data, locaData.length,
writeOffset + firstEntryLength); writeOffset + firstEntryLength);
} else { } else {
glyf.data = newGlyfData.subarray(0, writeOffset); glyf.data = newGlyfData.subarray(0, writeOffset);

View File

@ -39,6 +39,7 @@
!S2.pdf !S2.pdf
!helloworld-bad.pdf !helloworld-bad.pdf
!zerowidthline.pdf !zerowidthline.pdf
!bug868745.pdf
!issue1002.pdf !issue1002.pdf
!issue925.pdf !issue925.pdf
!gradientfill.pdf !gradientfill.pdf

BIN
test/pdfs/bug868745.pdf Normal file

Binary file not shown.

View File

@ -189,6 +189,12 @@
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "bug868745",
"file": "pdfs/bug868745.pdf",
"md5": "86111ea5097dd7daffcdea891ad1b348",
"rounds": 1,
"type": "load"
},
{ "id": "thuluthfont-pdf", { "id": "thuluthfont-pdf",
"file": "pdfs/ThuluthFeatures.pdf", "file": "pdfs/ThuluthFeatures.pdf",
"md5": "b7e18bf7a3d6a9c82aefa12d721072fc", "md5": "b7e18bf7a3d6a9c82aefa12d721072fc",