Overwrite glyphs contour count if it's less than -1.
The test pdf has a contour count of -70, but OTS doesn't like values less than -1. Fixes issue #7562.
This commit is contained in:
parent
56c14e27e6
commit
17037b5e51
@ -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;
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -188,6 +188,7 @@
|
||||
!issue2840.pdf
|
||||
!issue4061.pdf
|
||||
!issue4668.pdf
|
||||
!PDFJS-7562-reduced.pdf
|
||||
!issue5039.pdf
|
||||
!issue5070.pdf
|
||||
!issue5238.pdf
|
||||
|
BIN
test/pdfs/PDFJS-7562-reduced.pdf
Normal file
BIN
test/pdfs/PDFJS-7562-reduced.pdf
Normal file
Binary file not shown.
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user