Browse Source

PDF.js version 1.0.1141

master v1.0.1141
Pdf Bot 10 years ago
parent
commit
e73aeda675
  1. 2
      bower.json
  2. 62
      build/pdf.combined.js
  3. 4
      build/pdf.js
  4. 62
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.1137", "version": "1.0.1141",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

62
build/pdf.combined.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.1137'; PDFJS.version = '1.0.1141';
PDFJS.build = 'fb82000'; PDFJS.build = '394b38b';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -22619,6 +22619,10 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
} }
}, },
has: function(i) {
return this._map[i] !== undefined;
},
get: function(i) { get: function(i) {
return this._map[i]; return this._map[i];
}, },
@ -22648,6 +22652,10 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
} }
}, },
has: function (i) {
return this.firstChar <= i && i <= this.lastChar;
},
get: function (i) { get: function (i) {
if (this.firstChar <= i && i <= this.lastChar) { if (this.firstChar <= i && i <= this.lastChar) {
return String.fromCharCode(i); return String.fromCharCode(i);
@ -23080,7 +23088,6 @@ var Font = (function FontClosure() {
var isSymbolic = !!(properties.flags & FontFlags.Symbolic); var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
var isIdentityUnicode = var isIdentityUnicode =
properties.toUnicode instanceof IdentityToUnicodeMap; properties.toUnicode instanceof IdentityToUnicodeMap;
var isCidFontType2 = (properties.type === 'CIDFontType2');
var newMap = Object.create(null); var newMap = Object.create(null);
var toFontChar = []; var toFontChar = [];
var usedFontCharCodes = []; var usedFontCharCodes = [];
@ -23091,18 +23098,12 @@ var Font = (function FontClosure() {
var fontCharCode = originalCharCode; var fontCharCode = originalCharCode;
// First try to map the value to a unicode position if a non identity map // First try to map the value to a unicode position if a non identity map
// was created. // was created.
if (!isIdentityUnicode) { if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
if (toUnicode.get(originalCharCode) !== undefined) {
var unicode = toUnicode.get(fontCharCode); var unicode = toUnicode.get(fontCharCode);
// TODO: Try to map ligatures to the correct spot. // TODO: Try to map ligatures to the correct spot.
if (unicode.length === 1) { if (unicode.length === 1) {
fontCharCode = unicode.charCodeAt(0); fontCharCode = unicode.charCodeAt(0);
} }
} else if (isCidFontType2) {
// For CIDFontType2, move characters not present in toUnicode
// to the private use area (fixes bug 1028735 and issue 4881).
fontCharCode = nextAvailableFontCharCode;
}
} }
// Try to move control characters, special characters and already mapped // Try to move control characters, special characters and already mapped
// characters to the private use area since they will not be drawn by // characters to the private use area since they will not be drawn by
@ -23946,6 +23947,7 @@ var Font = (function FontClosure() {
var newGlyfData = new Uint8Array(oldGlyfDataLength); var newGlyfData = new Uint8Array(oldGlyfDataLength);
var startOffset = itemDecode(locaData, 0); var startOffset = itemDecode(locaData, 0);
var writeOffset = 0; var writeOffset = 0;
var missingGlyphData = {};
itemEncode(locaData, 0, writeOffset); itemEncode(locaData, 0, writeOffset);
var i, j; var i, j;
for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
@ -23963,6 +23965,10 @@ var Font = (function FontClosure() {
continue; continue;
} }
if (startOffset === endOffset) {
missingGlyphData[i] = true;
}
var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset,
newGlyfData, writeOffset, hintsValid); newGlyfData, writeOffset, hintsValid);
writeOffset += newLength; writeOffset += newLength;
@ -23979,7 +23985,7 @@ var Font = (function FontClosure() {
itemEncode(locaData, j, simpleGlyph.length); itemEncode(locaData, j, simpleGlyph.length);
} }
glyf.data = simpleGlyph; glyf.data = simpleGlyph;
return; return missingGlyphData;
} }
if (dupFirstEntry) { if (dupFirstEntry) {
@ -23996,6 +24002,7 @@ var Font = (function FontClosure() {
} else { } else {
glyf.data = newGlyfData.subarray(0, writeOffset); glyf.data = newGlyfData.subarray(0, writeOffset);
} }
return missingGlyphData;
} }
function readPostScriptTable(post, properties, maxpNumGlyphs) { function readPostScriptTable(post, properties, maxpNumGlyphs) {
@ -24455,11 +24462,13 @@ var Font = (function FontClosure() {
sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
var missingGlyphs = {};
if (isTrueType) { if (isTrueType) {
var isGlyphLocationsLong = int16(tables.head.data[50], var isGlyphLocationsLong = int16(tables.head.data[50],
tables.head.data[51]); tables.head.data[51]);
sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, missingGlyphs = sanitizeGlyphLocations(tables.loca, tables.glyf,
isGlyphLocationsLong, hintsValid, dupFirstEntry); numGlyphs, isGlyphLocationsLong,
hintsValid, dupFirstEntry);
} }
if (!tables.hhea) { if (!tables.hhea) {
@ -24481,19 +24490,33 @@ var Font = (function FontClosure() {
} }
} }
var charCodeToGlyphId = [], charCode; var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;
function hasGlyph(glyphId, charCode) {
if (!missingGlyphs[glyphId]) {
return true;
}
if (charCode >= 0 && toUnicode.has(charCode)) {
return true;
}
return false;
}
if (properties.type === 'CIDFontType2') { if (properties.type === 'CIDFontType2') {
var cidToGidMap = properties.cidToGidMap || []; var cidToGidMap = properties.cidToGidMap || [];
var cidToGidMapLength = cidToGidMap.length; var isCidToGidMapEmpty = cidToGidMap.length === 0;
properties.cMap.forEach(function(charCode, cid) { properties.cMap.forEach(function(charCode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535'); assert(cid <= 0xffff, 'Max size of CID is 65,535');
var glyphId = -1; var glyphId = -1;
if (cidToGidMapLength === 0) { if (isCidToGidMapEmpty) {
glyphId = charCode; glyphId = charCode;
} else if (cidToGidMap[cid] !== undefined) { } else if (cidToGidMap[cid] !== undefined) {
glyphId = cidToGidMap[cid]; glyphId = cidToGidMap[cid];
} }
if (glyphId >= 0 && glyphId < numGlyphs) {
if (glyphId >= 0 && glyphId < numGlyphs &&
hasGlyph(glyphId, charCode)) {
charCodeToGlyphId[charCode] = glyphId; charCodeToGlyphId[charCode] = glyphId;
} }
}); });
@ -24553,7 +24576,8 @@ var Font = (function FontClosure() {
var found = false; var found = false;
for (i = 0; i < cmapMappingsLength; ++i) { for (i = 0; i < cmapMappingsLength; ++i) {
if (cmapMappings[i].charCode === unicodeOrCharCode) { if (cmapMappings[i].charCode === unicodeOrCharCode &&
hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId; charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
found = true; found = true;
break; break;
@ -24563,7 +24587,7 @@ var Font = (function FontClosure() {
// Try to map using the post table. There are currently no known // Try to map using the post table. There are currently no known
// pdfs that this fixes. // pdfs that this fixes.
var glyphId = properties.glyphNames.indexOf(glyphName); var glyphId = properties.glyphNames.indexOf(glyphName);
if (glyphId > 0) { if (glyphId > 0 && hasGlyph(glyphId, -1)) {
charCodeToGlyphId[charCode] = glyphId; charCodeToGlyphId[charCode] = glyphId;
} }
} }

4
build/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.1137'; PDFJS.version = '1.0.1141';
PDFJS.build = 'fb82000'; PDFJS.build = '394b38b';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it

62
build/pdf.worker.js vendored

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.1137'; PDFJS.version = '1.0.1141';
PDFJS.build = 'fb82000'; PDFJS.build = '394b38b';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -16294,6 +16294,10 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
} }
}, },
has: function(i) {
return this._map[i] !== undefined;
},
get: function(i) { get: function(i) {
return this._map[i]; return this._map[i];
}, },
@ -16323,6 +16327,10 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
} }
}, },
has: function (i) {
return this.firstChar <= i && i <= this.lastChar;
},
get: function (i) { get: function (i) {
if (this.firstChar <= i && i <= this.lastChar) { if (this.firstChar <= i && i <= this.lastChar) {
return String.fromCharCode(i); return String.fromCharCode(i);
@ -16755,7 +16763,6 @@ var Font = (function FontClosure() {
var isSymbolic = !!(properties.flags & FontFlags.Symbolic); var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
var isIdentityUnicode = var isIdentityUnicode =
properties.toUnicode instanceof IdentityToUnicodeMap; properties.toUnicode instanceof IdentityToUnicodeMap;
var isCidFontType2 = (properties.type === 'CIDFontType2');
var newMap = Object.create(null); var newMap = Object.create(null);
var toFontChar = []; var toFontChar = [];
var usedFontCharCodes = []; var usedFontCharCodes = [];
@ -16766,18 +16773,12 @@ var Font = (function FontClosure() {
var fontCharCode = originalCharCode; var fontCharCode = originalCharCode;
// First try to map the value to a unicode position if a non identity map // First try to map the value to a unicode position if a non identity map
// was created. // was created.
if (!isIdentityUnicode) { if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
if (toUnicode.get(originalCharCode) !== undefined) {
var unicode = toUnicode.get(fontCharCode); var unicode = toUnicode.get(fontCharCode);
// TODO: Try to map ligatures to the correct spot. // TODO: Try to map ligatures to the correct spot.
if (unicode.length === 1) { if (unicode.length === 1) {
fontCharCode = unicode.charCodeAt(0); fontCharCode = unicode.charCodeAt(0);
} }
} else if (isCidFontType2) {
// For CIDFontType2, move characters not present in toUnicode
// to the private use area (fixes bug 1028735 and issue 4881).
fontCharCode = nextAvailableFontCharCode;
}
} }
// Try to move control characters, special characters and already mapped // Try to move control characters, special characters and already mapped
// characters to the private use area since they will not be drawn by // characters to the private use area since they will not be drawn by
@ -17621,6 +17622,7 @@ var Font = (function FontClosure() {
var newGlyfData = new Uint8Array(oldGlyfDataLength); var newGlyfData = new Uint8Array(oldGlyfDataLength);
var startOffset = itemDecode(locaData, 0); var startOffset = itemDecode(locaData, 0);
var writeOffset = 0; var writeOffset = 0;
var missingGlyphData = {};
itemEncode(locaData, 0, writeOffset); itemEncode(locaData, 0, writeOffset);
var i, j; var i, j;
for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
@ -17638,6 +17640,10 @@ var Font = (function FontClosure() {
continue; continue;
} }
if (startOffset === endOffset) {
missingGlyphData[i] = true;
}
var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset,
newGlyfData, writeOffset, hintsValid); newGlyfData, writeOffset, hintsValid);
writeOffset += newLength; writeOffset += newLength;
@ -17654,7 +17660,7 @@ var Font = (function FontClosure() {
itemEncode(locaData, j, simpleGlyph.length); itemEncode(locaData, j, simpleGlyph.length);
} }
glyf.data = simpleGlyph; glyf.data = simpleGlyph;
return; return missingGlyphData;
} }
if (dupFirstEntry) { if (dupFirstEntry) {
@ -17671,6 +17677,7 @@ var Font = (function FontClosure() {
} else { } else {
glyf.data = newGlyfData.subarray(0, writeOffset); glyf.data = newGlyfData.subarray(0, writeOffset);
} }
return missingGlyphData;
} }
function readPostScriptTable(post, properties, maxpNumGlyphs) { function readPostScriptTable(post, properties, maxpNumGlyphs) {
@ -18130,11 +18137,13 @@ var Font = (function FontClosure() {
sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
var missingGlyphs = {};
if (isTrueType) { if (isTrueType) {
var isGlyphLocationsLong = int16(tables.head.data[50], var isGlyphLocationsLong = int16(tables.head.data[50],
tables.head.data[51]); tables.head.data[51]);
sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, missingGlyphs = sanitizeGlyphLocations(tables.loca, tables.glyf,
isGlyphLocationsLong, hintsValid, dupFirstEntry); numGlyphs, isGlyphLocationsLong,
hintsValid, dupFirstEntry);
} }
if (!tables.hhea) { if (!tables.hhea) {
@ -18156,19 +18165,33 @@ var Font = (function FontClosure() {
} }
} }
var charCodeToGlyphId = [], charCode; var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;
function hasGlyph(glyphId, charCode) {
if (!missingGlyphs[glyphId]) {
return true;
}
if (charCode >= 0 && toUnicode.has(charCode)) {
return true;
}
return false;
}
if (properties.type === 'CIDFontType2') { if (properties.type === 'CIDFontType2') {
var cidToGidMap = properties.cidToGidMap || []; var cidToGidMap = properties.cidToGidMap || [];
var cidToGidMapLength = cidToGidMap.length; var isCidToGidMapEmpty = cidToGidMap.length === 0;
properties.cMap.forEach(function(charCode, cid) { properties.cMap.forEach(function(charCode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535'); assert(cid <= 0xffff, 'Max size of CID is 65,535');
var glyphId = -1; var glyphId = -1;
if (cidToGidMapLength === 0) { if (isCidToGidMapEmpty) {
glyphId = charCode; glyphId = charCode;
} else if (cidToGidMap[cid] !== undefined) { } else if (cidToGidMap[cid] !== undefined) {
glyphId = cidToGidMap[cid]; glyphId = cidToGidMap[cid];
} }
if (glyphId >= 0 && glyphId < numGlyphs) {
if (glyphId >= 0 && glyphId < numGlyphs &&
hasGlyph(glyphId, charCode)) {
charCodeToGlyphId[charCode] = glyphId; charCodeToGlyphId[charCode] = glyphId;
} }
}); });
@ -18228,7 +18251,8 @@ var Font = (function FontClosure() {
var found = false; var found = false;
for (i = 0; i < cmapMappingsLength; ++i) { for (i = 0; i < cmapMappingsLength; ++i) {
if (cmapMappings[i].charCode === unicodeOrCharCode) { if (cmapMappings[i].charCode === unicodeOrCharCode &&
hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId; charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
found = true; found = true;
break; break;
@ -18238,7 +18262,7 @@ var Font = (function FontClosure() {
// Try to map using the post table. There are currently no known // Try to map using the post table. There are currently no known
// pdfs that this fixes. // pdfs that this fixes.
var glyphId = properties.glyphNames.indexOf(glyphName); var glyphId = properties.glyphNames.indexOf(glyphName);
if (glyphId > 0) { if (glyphId > 0 && hasGlyph(glyphId, -1)) {
charCodeToGlyphId[charCode] = glyphId; charCodeToGlyphId[charCode] = glyphId;
} }
} }

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.1137", "version": "1.0.1141",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [
"Mozilla", "Mozilla",

Loading…
Cancel
Save