Merge remote-tracking branch 'mozilla/master' into bidi
Conflicts: src/fonts.js
This commit is contained in:
commit
a8cdbcf315
62
src/fonts.js
62
src/fonts.js
@ -11,6 +11,7 @@ var kMaxWaitForFontFace = 1000;
|
||||
// Unicode Private Use Area
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
var kSizeOfGlyphArea = 0x1900;
|
||||
var kSymbolicFontGlyphOffset = 0xF000;
|
||||
|
||||
// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
|
||||
// except for Type 3 fonts
|
||||
@ -1660,6 +1661,18 @@ var Font = (function FontClosure() {
|
||||
itemEncode(locaData, j, writeOffset);
|
||||
startOffset = endOffset;
|
||||
}
|
||||
|
||||
if (writeOffset == 0) {
|
||||
// glyf table cannot be empty -- redoing the glyf and loca tables
|
||||
// to have single glyph with one point
|
||||
var simpleGlyph = new Uint8Array(
|
||||
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
|
||||
for (var i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize)
|
||||
itemEncode(locaData, j, simpleGlyph.length);
|
||||
glyf.data = simpleGlyph;
|
||||
return;
|
||||
}
|
||||
|
||||
glyf.data = newGlyfData.subarray(0, writeOffset);
|
||||
}
|
||||
|
||||
@ -1887,8 +1900,8 @@ var Font = (function FontClosure() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if it is, replacing with meaningful toFontChar values
|
||||
if (isIdentity) {
|
||||
// if it is, replacing with meaningful toUnicode values
|
||||
if (isIdentity && !this.isSymbolicFont) {
|
||||
var usedUnicodes = [], unassignedUnicodeItems = [];
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var unicode = toFontChar[i + 1];
|
||||
@ -1941,6 +1954,16 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
}
|
||||
|
||||
// Moving all symbolic font glyphs into 0xF000 - 0xF0FF range.
|
||||
if (this.isSymbolicFont) {
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var code = glyphs[i].unicode;
|
||||
code = kSymbolicFontGlyphOffset | (code & 0xFF);
|
||||
glyphs[i].unicode = toFontChar[i] = code;
|
||||
}
|
||||
this.useToFontChar = true;
|
||||
}
|
||||
|
||||
// remove glyph references outside range of avaialable glyphs
|
||||
for (var i = 0, ii = ids.length; i < ii; i++) {
|
||||
if (ids[i] >= numGlyphs)
|
||||
@ -3349,7 +3372,9 @@ var Type2CFF = (function Type2CFFClosure() {
|
||||
parse: function cff_parse() {
|
||||
var header = this.parseHeader();
|
||||
var properties = this.properties;
|
||||
|
||||
var nameIndex = this.parseIndex(header.endPos);
|
||||
this.sanitizeName(nameIndex);
|
||||
|
||||
var dictIndex = this.parseIndex(nameIndex.endPos);
|
||||
if (dictIndex.length != 1)
|
||||
@ -3718,6 +3743,39 @@ var Type2CFF = (function Type2CFFClosure() {
|
||||
}
|
||||
return dict;
|
||||
},
|
||||
sanitizeName: function cff_sanitizeName(nameIndex) {
|
||||
// There should really only be one font, but loop to make sure.
|
||||
for (var i = 0, ii = nameIndex.length; i < ii; ++i) {
|
||||
var data = nameIndex.get(i).data;
|
||||
var length = data.length;
|
||||
if (length > 127)
|
||||
warn('Font had name longer than 127 chars, will be rejected.');
|
||||
// Only certain chars are permitted in the font name.
|
||||
for (var j = 0; j < length; ++j) {
|
||||
var c = data[j];
|
||||
if (j === 0 && c === 0)
|
||||
continue;
|
||||
if (c < 33 || c > 126) {
|
||||
data[j] = 95;
|
||||
continue;
|
||||
}
|
||||
switch (c) {
|
||||
case 91: // [
|
||||
case 93: // ]
|
||||
case 40: // (
|
||||
case 41: // )
|
||||
case 123: // {
|
||||
case 125: // }
|
||||
case 60: // <
|
||||
case 62: // >
|
||||
case 47: // /
|
||||
case 37: // %
|
||||
data[j] = 95;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getStrings: function cff_getStrings(stringIndex) {
|
||||
function bytesToString(bytesArray) {
|
||||
var str = '';
|
||||
|
22
src/jpx.js
22
src/jpx.js
@ -1052,7 +1052,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
r = 0;
|
||||
}
|
||||
error('JPX error: Out of packets');
|
||||
throw 'Out of packets';
|
||||
};
|
||||
}
|
||||
function ResolutionLayerComponentPositionIterator(context) {
|
||||
@ -1091,7 +1091,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
l = 0;
|
||||
}
|
||||
error('JPX error: Out of packets');
|
||||
throw 'Out of packets';
|
||||
};
|
||||
}
|
||||
function buildPackets(context) {
|
||||
@ -1187,7 +1187,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
new ResolutionLayerComponentPositionIterator(context);
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Unsupported progression order ' + progressionOrder);
|
||||
throw 'Unsupported progression order ' + progressionOrder;
|
||||
}
|
||||
}
|
||||
function parseTilePackets(context, data, offset, dataLength) {
|
||||
@ -1553,6 +1553,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
|
||||
function JpxImage() {
|
||||
this.failOnCorruptedImage = false;
|
||||
}
|
||||
JpxImage.prototype = {
|
||||
load: function jpxImageLoad(url) {
|
||||
@ -1612,6 +1613,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
},
|
||||
parseCodestream: function jpxImageParseCodestream(data, start, end) {
|
||||
var context = {};
|
||||
try {
|
||||
var position = start;
|
||||
while (position < end) {
|
||||
var code = readUint16(data, position);
|
||||
@ -1675,7 +1677,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Invalid SQcd value ' + sqcd);
|
||||
throw 'Invalid SQcd value ' + sqcd;
|
||||
}
|
||||
qcd.noQuantization = spqcdSize == 8;
|
||||
qcd.scalarExpounded = scalarExpounded;
|
||||
@ -1728,7 +1730,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Invalid SQcd value ' + sqcd);
|
||||
throw 'Invalid SQcd value ' + sqcd;
|
||||
}
|
||||
qcc.noQuantization = spqcdSize == 8;
|
||||
qcc.scalarExpounded = scalarExpounded;
|
||||
@ -1795,7 +1797,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
cod.terminationOnEachCodingPass ||
|
||||
cod.verticalyStripe || cod.predictableTermination ||
|
||||
cod.segmentationSymbolUsed)
|
||||
error('JPX error: Unsupported COD options: ' + uneval(cod));
|
||||
throw 'Unsupported COD options: ' + uneval(cod);
|
||||
|
||||
if (context.mainHeader)
|
||||
context.COD = cod;
|
||||
@ -1840,10 +1842,16 @@ var JpxImage = (function JpxImageClosure() {
|
||||
// skipping content
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Unknown codestream code: ' + code.toString(16));
|
||||
throw 'Unknown codestream code: ' + code.toString(16);
|
||||
}
|
||||
position += length;
|
||||
}
|
||||
} catch (e) {
|
||||
if (this.failOnCorruptedImage)
|
||||
error('JPX error: ' + e);
|
||||
else
|
||||
warn('JPX error: ' + e + '. Trying to recover');
|
||||
}
|
||||
this.tiles = transformComponents(context);
|
||||
this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
|
||||
this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -24,3 +24,4 @@
|
||||
!type4psfunc.pdf
|
||||
!S2.pdf
|
||||
!zerowidthline.pdf
|
||||
!issue925.pdf
|
||||
|
1
test/pdfs/issue1243.pdf.link
Normal file
1
test/pdfs/issue1243.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
http://www.nsa.gov/public_info/_files/nash_letters/nash_letters1.pdf
|
1
test/pdfs/issue1257.pdf.link
Normal file
1
test/pdfs/issue1257.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
http://hse-econ.fi/tervio/MediocritiesAndSuperstars.pdf
|
BIN
test/pdfs/issue925.pdf
Executable file
BIN
test/pdfs/issue925.pdf
Executable file
Binary file not shown.
@ -460,6 +460,13 @@
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue925",
|
||||
"file": "pdfs/issue925.pdf",
|
||||
"md5": "f58fe943090aff89dcc8e771bc0db4c2",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1133",
|
||||
"file": "pdfs/issue1133.pdf",
|
||||
"md5": "d1b61580cb100e3df93d33703af1773a",
|
||||
@ -480,5 +487,21 @@
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1243",
|
||||
"file": "pdfs/issue1243.pdf",
|
||||
"md5": "130c849b83513d5ac5e03c6421fc7489",
|
||||
"rounds": 1,
|
||||
"pageLimit": 2,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1257",
|
||||
"file": "pdfs/issue1257.pdf",
|
||||
"md5": "9111533826bc21ed774e8e01603a2f54",
|
||||
"rounds": 1,
|
||||
"pageLimit": 2,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user