diff --git a/src/core/fonts.js b/src/core/fonts.js index ecd68f8f9..4d7354648 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 07539309b..0d667048c 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -188,6 +188,7 @@ !issue2840.pdf !issue4061.pdf !issue4668.pdf +!PDFJS-7562-reduced.pdf !issue5039.pdf !issue5070.pdf !issue5238.pdf diff --git a/test/pdfs/PDFJS-7562-reduced.pdf b/test/pdfs/PDFJS-7562-reduced.pdf new file mode 100644 index 000000000..3ec043706 Binary files /dev/null and b/test/pdfs/PDFJS-7562-reduced.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 41947059e..02366eb29 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",