Browse Source

PDF.js version 1.0.235

master v1.0.235
Yury Delendik 10 years ago
parent
commit
8743d88a06
  1. 2
      bower.json
  2. 218
      build/pdf.combined.js
  3. 11
      build/pdf.js
  4. 211
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.233", "version": "1.0.235",
"keywords": [ "keywords": [
"Mozilla", "Mozilla",
"pdf", "pdf",

218
build/pdf.combined.js

@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.233'; PDFJS.version = '1.0.235';
PDFJS.build = 'd39af0a'; PDFJS.build = 'fe27a76';
(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
@ -6487,7 +6487,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.font = fontObj; this.current.font = fontObj;
this.current.fontSize = size; this.current.fontSize = size;
if (fontObj.coded) { if (fontObj.isType3Font) {
return; // we don't need ctx.font for Type3 fonts return; // we don't need ctx.font for Type3 fonts
} }
@ -6634,7 +6634,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
// Type3 fonts - each glyph is a "mini-PDF" // Type3 fonts - each glyph is a "mini-PDF"
if (font.coded) { if (font.isType3Font) {
ctx.save(); ctx.save();
ctx.transform.apply(ctx, current.textMatrix); ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y); ctx.translate(current.x, current.y);
@ -6654,7 +6654,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.save(); this.save();
ctx.scale(fontSize, fontSize); ctx.scale(fontSize, fontSize);
ctx.transform.apply(ctx, fontMatrix); ctx.transform.apply(ctx, fontMatrix);
this.executeOperatorList(glyph.operatorList); var operatorList = font.charProcOperatorList[glyph.operatorListId];
this.executeOperatorList(operatorList);
this.restore(); this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
@ -10493,7 +10494,6 @@ var Catalog = (function CatalogClosure() {
}); });
return Promise.all(promises).then(function (fonts) { return Promise.all(promises).then(function (fonts) {
for (var i = 0, ii = fonts.length; i < ii; i++) { for (var i = 0, ii = fonts.length; i < ii; i++) {
delete fonts[i].sent;
delete fonts[i].translated; delete fonts[i].translated;
} }
this.fontCache.clear(); this.fontCache.clear();
@ -20347,28 +20347,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
fontArgs = fontArgs.slice(); fontArgs = fontArgs.slice();
fontName = fontArgs[0].name; fontName = fontArgs[0].name;
} }
var self = this;
return this.loadFont(fontName, fontRef, this.xref, resources,
operatorList).then(function (font) {
state.font = font;
var loadedName = font.loadedName;
if (!font.sent) {
var fontData = font.translated.exportData();
self.handler.send('commonobj', [
loadedName,
'Font',
fontData
]);
font.sent = true;
}
return loadedName; var self = this;
return this.loadFont(fontName, fontRef, this.xref, resources).then(
function (translated) {
if (!translated.font.isType3Font) {
return translated;
}
return translated.loadType3Data(self, resources, operatorList).then(
function () {
return translated;
}); });
}).then(function (translated) {
state.font = translated.font;
translated.send(self.handler);
return translated.loadedName;
});
}, },
handleText: function PartialEvaluator_handleText(chars, state) { handleText: function PartialEvaluator_handleText(chars, state) {
var font = state.font.translated; var font = state.font;
var glyphs = font.charsToGlyphs(chars); var glyphs = font.charsToGlyphs(chars);
var isAddToPathSet = !!(state.textRenderingMode & var isAddToPathSet = !!(state.textRenderingMode &
TextRenderingMode.ADD_TO_PATH_FLAG); TextRenderingMode.ADD_TO_PATH_FLAG);
@ -20494,16 +20492,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}, },
loadFont: function PartialEvaluator_loadFont(fontName, font, xref, loadFont: function PartialEvaluator_loadFont(fontName, font, xref,
resources, resources) {
parentOperatorList) {
function errorFont() { function errorFont() {
return Promise.resolve({ return Promise.resolve(new TranslatedFont('g_font_error',
translated: new ErrorFont('Font ' + fontName + ' is not available'), new ErrorFont('Font ' + fontName + ' is not available'), font));
loadedName: 'g_font_error'
});
} }
var fontRef; var fontRef;
if (font) { // Loading by ref. if (font) { // Loading by ref.
assert(isRef(font)); assert(isRef(font));
@ -20526,6 +20520,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return errorFont(); return errorFont();
} }
// We are holding font.translated references just for fontRef that are not
// dictionaries (Dict). See explanation below.
if (font.translated) {
return font.translated;
}
var fontCapability = createPromiseCapability(); var fontCapability = createPromiseCapability();
var preEvaluatedFont = this.preEvaluateFont(font, xref); var preEvaluatedFont = this.preEvaluateFont(font, xref);
@ -20542,8 +20542,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var aliasFontRef = fontAliases[hash].aliasRef; var aliasFontRef = fontAliases[hash].aliasRef;
if (aliasFontRef && this.fontCache.has(aliasFontRef)) { if (aliasFontRef && this.fontCache.has(aliasFontRef)) {
this.fontCache.putAlias(fontRef, aliasFontRef); this.fontCache.putAlias(fontRef, aliasFontRef);
var cachedFont = this.fontCache.get(fontRef); return this.fontCache.get(fontRef);
return cachedFont;
} }
} }
@ -20572,49 +20571,28 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
font.loadedName = 'g_font_' + (fontRefIsDict ? font.loadedName = 'g_font_' + (fontRefIsDict ?
fontName.replace(/\W/g, '') : fontID); fontName.replace(/\W/g, '') : fontID);
if (!font.translated) { font.translated = fontCapability.promise;
var translated;
try {
translated = this.translateFont(preEvaluatedFont, xref);
} catch (e) {
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
translated = new ErrorFont(e instanceof Error ? e.message : e);
}
font.translated = translated;
}
var loadCharProcsPromise = Promise.resolve(); // TODO move promises into translate font
if (font.translated.loadCharProcs) { var translatedPromise;
var charProcs = font.get('CharProcs').getAll(); try {
var fontResources = (font.get('Resources') || resources); translatedPromise = Promise.resolve(
var charProcKeys = Object.keys(charProcs); this.translateFont(preEvaluatedFont, xref));
var charProcOperatorList = {}; } catch (e) {
for (var i = 0, n = charProcKeys.length; i < n; ++i) { translatedPromise = Promise.reject(e);
loadCharProcsPromise = loadCharProcsPromise.then(function (key) { }
var glyphStream = charProcs[key];
var operatorList = new OperatorList(); translatedPromise.then(function (translatedFont) {
return this.getOperatorList(glyphStream, fontResources, fontCapability.resolve(new TranslatedFont(font.loadedName,
operatorList). translatedFont, font));
then(function () { }, function (reason) {
charProcOperatorList[key] = operatorList.getIR(); // TODO fontCapability.reject?
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
// Add the dependencies to the parent operator list so they are fontCapability.resolve(new TranslatedFont(font.loadedName,
// resolved before sub operator list is executed synchronously. new ErrorFont(reason instanceof Error ? reason.message : reason),
if (parentOperatorList) { font));
parentOperatorList.addDependencies(operatorList.dependencies); });
} return fontCapability.promise;
});
}.bind(this, charProcKeys[i]));
}
loadCharProcsPromise = loadCharProcsPromise.then(function () {
font.translated.charProcOperatorList = charProcOperatorList;
});
}
return loadCharProcsPromise.then(function () {
font.loaded = true;
fontCapability.resolve(font);
return fontCapability.promise;
}, fontCapability.reject);
}, },
buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) { buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
@ -20885,11 +20863,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} }
function handleSetFont(fontName, fontRef) { function handleSetFont(fontName, fontRef) {
return self.loadFont(fontName, fontRef, xref, resources, null). return self.loadFont(fontName, fontRef, xref, resources).
then(function (font) { then(function (translated) {
var fontTranslated = textState.font = font.translated; textState.font = translated.font;
textState.fontMatrix = fontTranslated.fontMatrix ? textState.fontMatrix = translated.font.fontMatrix ||
fontTranslated.fontMatrix :
FONT_IDENTITY_MATRIX; FONT_IDENTITY_MATRIX;
}); });
} }
@ -21664,7 +21641,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
this.extractWidths(dict, xref, descriptor, properties); this.extractWidths(dict, xref, descriptor, properties);
if (type.name === 'Type3') { if (type.name === 'Type3') {
properties.coded = true; properties.isType3Font = true;
} }
return new Font(fontName.name, fontFile, properties); return new Font(fontName.name, fontFile, properties);
@ -21674,6 +21651,64 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return PartialEvaluator; return PartialEvaluator;
})(); })();
var TranslatedFont = (function TranslatedFontClosure() {
function TranslatedFont(loadedName, font, dict) {
this.loadedName = loadedName;
this.font = font;
this.dict = dict;
this.type3Loaded = null;
this.sent = false;
}
TranslatedFont.prototype = {
send: function (handler) {
if (this.sent) {
return;
}
var fontData = this.font.exportData();
handler.send('commonobj', [
this.loadedName,
'Font',
fontData
]);
this.sent = true;
},
loadType3Data: function (evaluator, resources, parentOperatorList) {
assert(this.font.isType3Font);
if (this.type3Loaded) {
return this.type3Loaded;
}
var translatedFont = this.font;
var loadCharProcsPromise = Promise.resolve();
var charProcs = this.dict.get('CharProcs').getAll();
var fontResources = this.dict.get('Resources') || resources;
var charProcKeys = Object.keys(charProcs);
var charProcOperatorList = {};
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
var glyphStream = charProcs[key];
var operatorList = new OperatorList();
return evaluator.getOperatorList(glyphStream, fontResources,
operatorList).
then(function () {
charProcOperatorList[key] = operatorList.getIR();
// Add the dependencies to the parent operator list so they are
// resolved before sub operator list is executed synchronously.
parentOperatorList.addDependencies(operatorList.dependencies);
});
}.bind(this, charProcKeys[i]));
}
this.type3Loaded = loadCharProcsPromise.then(function () {
translatedFont.charProcOperatorList = charProcOperatorList;
});
return this.type3Loaded;
}
};
return TranslatedFont;
})();
var OperatorList = (function OperatorListClosure() { var OperatorList = (function OperatorListClosure() {
var CHUNK_SIZE = 1000; var CHUNK_SIZE = 1000;
var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size
@ -25334,23 +25369,23 @@ function adjustWidths(properties) {
} }
var Glyph = (function GlyphClosure() { var Glyph = (function GlyphClosure() {
function Glyph(fontChar, unicode, accent, width, vmetric, operatorList) { function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId) {
this.fontChar = fontChar; this.fontChar = fontChar;
this.unicode = unicode; this.unicode = unicode;
this.accent = accent; this.accent = accent;
this.width = width; this.width = width;
this.vmetric = vmetric; this.vmetric = vmetric;
this.operatorList = operatorList; this.operatorListId = operatorListId;
} }
Glyph.prototype.matchesForCache = Glyph.prototype.matchesForCache =
function(fontChar, unicode, accent, width, vmetric, operatorList) { function(fontChar, unicode, accent, width, vmetric, operatorListId) {
return this.fontChar === fontChar && return this.fontChar === fontChar &&
this.unicode === unicode && this.unicode === unicode &&
this.accent === accent && this.accent === accent &&
this.width === width && this.width === width &&
this.vmetric === vmetric && this.vmetric === vmetric &&
this.operatorList === operatorList; this.operatorListId === operatorListId;
}; };
return Glyph; return Glyph;
@ -25370,8 +25405,7 @@ var Font = (function FontClosure() {
this.name = name; this.name = name;
this.loadedName = properties.loadedName; this.loadedName = properties.loadedName;
this.coded = properties.coded; this.isType3Font = properties.isType3Font;
this.loadCharProcs = properties.coded;
this.sizes = []; this.sizes = [];
this.glyphCache = {}; this.glyphCache = {};
@ -27592,7 +27626,7 @@ var Font = (function FontClosure() {
}, },
charToGlyph: function Font_charToGlyph(charcode) { charToGlyph: function Font_charToGlyph(charcode) {
var fontCharCode, width, operatorList; var fontCharCode, width, operatorListId;
var widthCode = charcode; var widthCode = charcode;
if (this.cMap && charcode in this.cMap.map) { if (this.cMap && charcode in this.cMap.map) {
@ -27614,9 +27648,9 @@ var Font = (function FontClosure() {
fontCharCode = mapSpecialUnicodeValues(fontCharCode); fontCharCode = mapSpecialUnicodeValues(fontCharCode);
} }
if (this.type === 'Type3') { if (this.isType3Font) {
// Font char code in this case is actually a glyph name. // Font char code in this case is actually a glyph name.
operatorList = this.charProcOperatorList[fontCharCode]; operatorListId = fontCharCode;
} }
var accent = null; var accent = null;
@ -27634,9 +27668,9 @@ var Font = (function FontClosure() {
var glyph = this.glyphCache[charcode]; var glyph = this.glyphCache[charcode];
if (!glyph || if (!glyph ||
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
operatorList)) { operatorListId)) {
glyph = new Glyph(fontChar, unicode, accent, width, vmetric, glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
operatorList); operatorListId);
this.glyphCache[charcode] = glyph; this.glyphCache[charcode] = glyph;
} }
return glyph; return glyph;
@ -27701,6 +27735,8 @@ var Font = (function FontClosure() {
var ErrorFont = (function ErrorFontClosure() { var ErrorFont = (function ErrorFontClosure() {
function ErrorFont(error) { function ErrorFont(error) {
this.error = error; this.error = error;
this.loadedName = 'g_font_error';
this.loading = false;
} }
ErrorFont.prototype = { ErrorFont.prototype = {

11
build/pdf.js

@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.233'; PDFJS.version = '1.0.235';
PDFJS.build = 'd39af0a'; PDFJS.build = 'fe27a76';
(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
@ -6535,7 +6535,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.font = fontObj; this.current.font = fontObj;
this.current.fontSize = size; this.current.fontSize = size;
if (fontObj.coded) { if (fontObj.isType3Font) {
return; // we don't need ctx.font for Type3 fonts return; // we don't need ctx.font for Type3 fonts
} }
@ -6682,7 +6682,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
// Type3 fonts - each glyph is a "mini-PDF" // Type3 fonts - each glyph is a "mini-PDF"
if (font.coded) { if (font.isType3Font) {
ctx.save(); ctx.save();
ctx.transform.apply(ctx, current.textMatrix); ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y); ctx.translate(current.x, current.y);
@ -6702,7 +6702,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.save(); this.save();
ctx.scale(fontSize, fontSize); ctx.scale(fontSize, fontSize);
ctx.transform.apply(ctx, fontMatrix); ctx.transform.apply(ctx, fontMatrix);
this.executeOperatorList(glyph.operatorList); var operatorList = font.charProcOperatorList[glyph.operatorListId];
this.executeOperatorList(operatorList);
this.restore(); this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);

211
build/pdf.worker.js vendored

@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.233'; PDFJS.version = '1.0.235';
PDFJS.build = 'd39af0a'; PDFJS.build = 'fe27a76';
(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
@ -5900,7 +5900,6 @@ var Catalog = (function CatalogClosure() {
}); });
return Promise.all(promises).then(function (fonts) { return Promise.all(promises).then(function (fonts) {
for (var i = 0, ii = fonts.length; i < ii; i++) { for (var i = 0, ii = fonts.length; i < ii; i++) {
delete fonts[i].sent;
delete fonts[i].translated; delete fonts[i].translated;
} }
this.fontCache.clear(); this.fontCache.clear();
@ -15754,28 +15753,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
fontArgs = fontArgs.slice(); fontArgs = fontArgs.slice();
fontName = fontArgs[0].name; fontName = fontArgs[0].name;
} }
var self = this;
return this.loadFont(fontName, fontRef, this.xref, resources,
operatorList).then(function (font) {
state.font = font;
var loadedName = font.loadedName;
if (!font.sent) {
var fontData = font.translated.exportData();
self.handler.send('commonobj', [
loadedName,
'Font',
fontData
]);
font.sent = true;
}
return loadedName; var self = this;
return this.loadFont(fontName, fontRef, this.xref, resources).then(
function (translated) {
if (!translated.font.isType3Font) {
return translated;
}
return translated.loadType3Data(self, resources, operatorList).then(
function () {
return translated;
}); });
}).then(function (translated) {
state.font = translated.font;
translated.send(self.handler);
return translated.loadedName;
});
}, },
handleText: function PartialEvaluator_handleText(chars, state) { handleText: function PartialEvaluator_handleText(chars, state) {
var font = state.font.translated; var font = state.font;
var glyphs = font.charsToGlyphs(chars); var glyphs = font.charsToGlyphs(chars);
var isAddToPathSet = !!(state.textRenderingMode & var isAddToPathSet = !!(state.textRenderingMode &
TextRenderingMode.ADD_TO_PATH_FLAG); TextRenderingMode.ADD_TO_PATH_FLAG);
@ -15901,16 +15898,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}, },
loadFont: function PartialEvaluator_loadFont(fontName, font, xref, loadFont: function PartialEvaluator_loadFont(fontName, font, xref,
resources, resources) {
parentOperatorList) {
function errorFont() { function errorFont() {
return Promise.resolve({ return Promise.resolve(new TranslatedFont('g_font_error',
translated: new ErrorFont('Font ' + fontName + ' is not available'), new ErrorFont('Font ' + fontName + ' is not available'), font));
loadedName: 'g_font_error'
});
} }
var fontRef; var fontRef;
if (font) { // Loading by ref. if (font) { // Loading by ref.
assert(isRef(font)); assert(isRef(font));
@ -15933,6 +15926,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return errorFont(); return errorFont();
} }
// We are holding font.translated references just for fontRef that are not
// dictionaries (Dict). See explanation below.
if (font.translated) {
return font.translated;
}
var fontCapability = createPromiseCapability(); var fontCapability = createPromiseCapability();
var preEvaluatedFont = this.preEvaluateFont(font, xref); var preEvaluatedFont = this.preEvaluateFont(font, xref);
@ -15949,8 +15948,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var aliasFontRef = fontAliases[hash].aliasRef; var aliasFontRef = fontAliases[hash].aliasRef;
if (aliasFontRef && this.fontCache.has(aliasFontRef)) { if (aliasFontRef && this.fontCache.has(aliasFontRef)) {
this.fontCache.putAlias(fontRef, aliasFontRef); this.fontCache.putAlias(fontRef, aliasFontRef);
var cachedFont = this.fontCache.get(fontRef); return this.fontCache.get(fontRef);
return cachedFont;
} }
} }
@ -15979,49 +15977,28 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
font.loadedName = 'g_font_' + (fontRefIsDict ? font.loadedName = 'g_font_' + (fontRefIsDict ?
fontName.replace(/\W/g, '') : fontID); fontName.replace(/\W/g, '') : fontID);
if (!font.translated) { font.translated = fontCapability.promise;
var translated;
try {
translated = this.translateFont(preEvaluatedFont, xref);
} catch (e) {
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
translated = new ErrorFont(e instanceof Error ? e.message : e);
}
font.translated = translated;
}
var loadCharProcsPromise = Promise.resolve(); // TODO move promises into translate font
if (font.translated.loadCharProcs) { var translatedPromise;
var charProcs = font.get('CharProcs').getAll(); try {
var fontResources = (font.get('Resources') || resources); translatedPromise = Promise.resolve(
var charProcKeys = Object.keys(charProcs); this.translateFont(preEvaluatedFont, xref));
var charProcOperatorList = {}; } catch (e) {
for (var i = 0, n = charProcKeys.length; i < n; ++i) { translatedPromise = Promise.reject(e);
loadCharProcsPromise = loadCharProcsPromise.then(function (key) { }
var glyphStream = charProcs[key];
var operatorList = new OperatorList(); translatedPromise.then(function (translatedFont) {
return this.getOperatorList(glyphStream, fontResources, fontCapability.resolve(new TranslatedFont(font.loadedName,
operatorList). translatedFont, font));
then(function () { }, function (reason) {
charProcOperatorList[key] = operatorList.getIR(); // TODO fontCapability.reject?
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
// Add the dependencies to the parent operator list so they are fontCapability.resolve(new TranslatedFont(font.loadedName,
// resolved before sub operator list is executed synchronously. new ErrorFont(reason instanceof Error ? reason.message : reason),
if (parentOperatorList) { font));
parentOperatorList.addDependencies(operatorList.dependencies); });
} return fontCapability.promise;
});
}.bind(this, charProcKeys[i]));
}
loadCharProcsPromise = loadCharProcsPromise.then(function () {
font.translated.charProcOperatorList = charProcOperatorList;
});
}
return loadCharProcsPromise.then(function () {
font.loaded = true;
fontCapability.resolve(font);
return fontCapability.promise;
}, fontCapability.reject);
}, },
buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) { buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
@ -16292,11 +16269,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} }
function handleSetFont(fontName, fontRef) { function handleSetFont(fontName, fontRef) {
return self.loadFont(fontName, fontRef, xref, resources, null). return self.loadFont(fontName, fontRef, xref, resources).
then(function (font) { then(function (translated) {
var fontTranslated = textState.font = font.translated; textState.font = translated.font;
textState.fontMatrix = fontTranslated.fontMatrix ? textState.fontMatrix = translated.font.fontMatrix ||
fontTranslated.fontMatrix :
FONT_IDENTITY_MATRIX; FONT_IDENTITY_MATRIX;
}); });
} }
@ -17071,7 +17047,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
this.extractWidths(dict, xref, descriptor, properties); this.extractWidths(dict, xref, descriptor, properties);
if (type.name === 'Type3') { if (type.name === 'Type3') {
properties.coded = true; properties.isType3Font = true;
} }
return new Font(fontName.name, fontFile, properties); return new Font(fontName.name, fontFile, properties);
@ -17081,6 +17057,64 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return PartialEvaluator; return PartialEvaluator;
})(); })();
var TranslatedFont = (function TranslatedFontClosure() {
function TranslatedFont(loadedName, font, dict) {
this.loadedName = loadedName;
this.font = font;
this.dict = dict;
this.type3Loaded = null;
this.sent = false;
}
TranslatedFont.prototype = {
send: function (handler) {
if (this.sent) {
return;
}
var fontData = this.font.exportData();
handler.send('commonobj', [
this.loadedName,
'Font',
fontData
]);
this.sent = true;
},
loadType3Data: function (evaluator, resources, parentOperatorList) {
assert(this.font.isType3Font);
if (this.type3Loaded) {
return this.type3Loaded;
}
var translatedFont = this.font;
var loadCharProcsPromise = Promise.resolve();
var charProcs = this.dict.get('CharProcs').getAll();
var fontResources = this.dict.get('Resources') || resources;
var charProcKeys = Object.keys(charProcs);
var charProcOperatorList = {};
for (var i = 0, n = charProcKeys.length; i < n; ++i) {
loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
var glyphStream = charProcs[key];
var operatorList = new OperatorList();
return evaluator.getOperatorList(glyphStream, fontResources,
operatorList).
then(function () {
charProcOperatorList[key] = operatorList.getIR();
// Add the dependencies to the parent operator list so they are
// resolved before sub operator list is executed synchronously.
parentOperatorList.addDependencies(operatorList.dependencies);
});
}.bind(this, charProcKeys[i]));
}
this.type3Loaded = loadCharProcsPromise.then(function () {
translatedFont.charProcOperatorList = charProcOperatorList;
});
return this.type3Loaded;
}
};
return TranslatedFont;
})();
var OperatorList = (function OperatorListClosure() { var OperatorList = (function OperatorListClosure() {
var CHUNK_SIZE = 1000; var CHUNK_SIZE = 1000;
var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size
@ -20741,23 +20775,23 @@ function adjustWidths(properties) {
} }
var Glyph = (function GlyphClosure() { var Glyph = (function GlyphClosure() {
function Glyph(fontChar, unicode, accent, width, vmetric, operatorList) { function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId) {
this.fontChar = fontChar; this.fontChar = fontChar;
this.unicode = unicode; this.unicode = unicode;
this.accent = accent; this.accent = accent;
this.width = width; this.width = width;
this.vmetric = vmetric; this.vmetric = vmetric;
this.operatorList = operatorList; this.operatorListId = operatorListId;
} }
Glyph.prototype.matchesForCache = Glyph.prototype.matchesForCache =
function(fontChar, unicode, accent, width, vmetric, operatorList) { function(fontChar, unicode, accent, width, vmetric, operatorListId) {
return this.fontChar === fontChar && return this.fontChar === fontChar &&
this.unicode === unicode && this.unicode === unicode &&
this.accent === accent && this.accent === accent &&
this.width === width && this.width === width &&
this.vmetric === vmetric && this.vmetric === vmetric &&
this.operatorList === operatorList; this.operatorListId === operatorListId;
}; };
return Glyph; return Glyph;
@ -20777,8 +20811,7 @@ var Font = (function FontClosure() {
this.name = name; this.name = name;
this.loadedName = properties.loadedName; this.loadedName = properties.loadedName;
this.coded = properties.coded; this.isType3Font = properties.isType3Font;
this.loadCharProcs = properties.coded;
this.sizes = []; this.sizes = [];
this.glyphCache = {}; this.glyphCache = {};
@ -22999,7 +23032,7 @@ var Font = (function FontClosure() {
}, },
charToGlyph: function Font_charToGlyph(charcode) { charToGlyph: function Font_charToGlyph(charcode) {
var fontCharCode, width, operatorList; var fontCharCode, width, operatorListId;
var widthCode = charcode; var widthCode = charcode;
if (this.cMap && charcode in this.cMap.map) { if (this.cMap && charcode in this.cMap.map) {
@ -23021,9 +23054,9 @@ var Font = (function FontClosure() {
fontCharCode = mapSpecialUnicodeValues(fontCharCode); fontCharCode = mapSpecialUnicodeValues(fontCharCode);
} }
if (this.type === 'Type3') { if (this.isType3Font) {
// Font char code in this case is actually a glyph name. // Font char code in this case is actually a glyph name.
operatorList = this.charProcOperatorList[fontCharCode]; operatorListId = fontCharCode;
} }
var accent = null; var accent = null;
@ -23041,9 +23074,9 @@ var Font = (function FontClosure() {
var glyph = this.glyphCache[charcode]; var glyph = this.glyphCache[charcode];
if (!glyph || if (!glyph ||
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
operatorList)) { operatorListId)) {
glyph = new Glyph(fontChar, unicode, accent, width, vmetric, glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
operatorList); operatorListId);
this.glyphCache[charcode] = glyph; this.glyphCache[charcode] = glyph;
} }
return glyph; return glyph;
@ -23108,6 +23141,8 @@ var Font = (function FontClosure() {
var ErrorFont = (function ErrorFontClosure() { var ErrorFont = (function ErrorFontClosure() {
function ErrorFont(error) { function ErrorFont(error) {
this.error = error; this.error = error;
this.loadedName = 'g_font_error';
this.loading = false;
} }
ErrorFont.prototype = { ErrorFont.prototype = {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.233", "version": "1.0.235",
"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