Merge pull request #9082 from brendandahl/issue7562

Overwrite glyphs contour count if it's less than -1.
This commit is contained in:
Jonas Jenwald 2017-10-30 20:44:01 +01:00 committed by GitHub
commit 92fcfce685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -649,6 +649,11 @@ var Font = (function FontClosure() {
return (b0 << 8) + b1;
}
function writeSignedInt16(bytes, index, value) {
bytes[index + 1] = value;
bytes[index] = value >>> 8;
}
function signedInt16(b0, b1) {
var value = (b0 << 8) + b1;
return value & (1 << 15) ? value - 0x10000 : value;
@ -1577,8 +1582,11 @@ var Font = (function FontClosure() {
return glyphProfile;
}
var glyf = source.subarray(sourceStart, sourceEnd);
var contoursCount = (glyf[0] << 8) | glyf[1];
if (contoursCount & 0x8000) {
var contoursCount = signedInt16(glyf[0], glyf[1]);
if (contoursCount < 0) {
// OTS doesn't like contour count to be less than -1.
contoursCount = -1;
writeSignedInt16(glyf, 0, contoursCount);
// complex glyph, writing as is
dest.set(glyf, destStart);
glyphProfile.length = glyf.length;

View File

@ -189,6 +189,7 @@
!issue2840.pdf
!issue4061.pdf
!issue4668.pdf
!PDFJS-7562-reduced.pdf
!issue5039.pdf
!issue5070.pdf
!issue5238.pdf

Binary file not shown.

View File

@ -419,6 +419,12 @@
"rounds": 1,
"type": "eq"
},
{ "id": "PDFJS-7562-reduced",
"file": "pdfs/PDFJS-7562-reduced.pdf",
"md5": "ddfb96fd492599fe54adbc685493ba3a",
"rounds": 1,
"type": "eq"
},
{ "id": "issue3694_reduced",
"file": "pdfs/issue3694_reduced.pdf",
"md5": "c1438c7bad12d70c4cd684f8ce04448f",