Merge pull request #2050 from yurydelendik/issue-2040
Fixes incorrect font type and prevents future this.objs.objs[fonts[i]] ...
This commit is contained in:
commit
8e50da78ee
17
src/api.js
17
src/api.js
@ -311,13 +311,19 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
ensureFonts: function PDFPageProxy_ensureFonts(fonts, callback) {
|
ensureFonts: function PDFPageProxy_ensureFonts(fonts, callback) {
|
||||||
this.stats.time('Font Loading');
|
this.stats.time('Font Loading');
|
||||||
// Convert the font names to the corresponding font obj.
|
// Convert the font names to the corresponding font obj.
|
||||||
|
var fontObjs = [];
|
||||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||||
fonts[i] = this.objs.objs[fonts[i]].data;
|
var obj = this.objs.objs[fonts[i]].data;
|
||||||
|
if (obj.error) {
|
||||||
|
warn('Error during font loading: ' + obj.error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fontObjs.push(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all the fonts
|
// Load all the fonts
|
||||||
FontLoader.bind(
|
FontLoader.bind(
|
||||||
fonts,
|
fontObjs,
|
||||||
function pageEnsureFontsFontObjs(fontObjs) {
|
function pageEnsureFontsFontObjs(fontObjs) {
|
||||||
this.stats.timeEnd('Font Loading');
|
this.stats.timeEnd('Font Loading');
|
||||||
|
|
||||||
@ -565,7 +571,12 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
|
|
||||||
// At this point, only the font object is created but the font is
|
// At this point, only the font object is created but the font is
|
||||||
// not yet attached to the DOM. This is done in `FontLoader.bind`.
|
// not yet attached to the DOM. This is done in `FontLoader.bind`.
|
||||||
var font = new Font(name, file, properties);
|
var font;
|
||||||
|
try {
|
||||||
|
font = new Font(name, file, properties);
|
||||||
|
} catch (e) {
|
||||||
|
font = new ErrorFont(e);
|
||||||
|
}
|
||||||
this.objs.resolve(id, font);
|
this.objs.resolve(id, font);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
22
src/fonts.js
22
src/fonts.js
@ -1577,13 +1577,19 @@ var Font = (function FontClosure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some fonts might use wrong font types for Type1C or CIDFontType0C
|
||||||
|
var subtype = properties.subtype;
|
||||||
|
if (subtype == 'Type1C' && (type != 'Type1' && type != 'MMType1'))
|
||||||
|
type = 'Type1';
|
||||||
|
if (subtype == 'CIDFontType0C' && type != 'CIDFontType0')
|
||||||
|
type = 'CIDFontType0';
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Type1':
|
case 'Type1':
|
||||||
case 'CIDFontType0':
|
case 'CIDFontType0':
|
||||||
this.mimetype = 'font/opentype';
|
this.mimetype = 'font/opentype';
|
||||||
|
|
||||||
var subtype = properties.subtype;
|
|
||||||
var cff = (subtype == 'Type1C' || subtype == 'CIDFontType0C') ?
|
var cff = (subtype == 'Type1C' || subtype == 'CIDFontType0C') ?
|
||||||
new CFFFont(file, properties) : new Type1Font(name, file, properties);
|
new CFFFont(file, properties) : new Type1Font(name, file, properties);
|
||||||
|
|
||||||
@ -3310,6 +3316,20 @@ var Font = (function FontClosure() {
|
|||||||
return Font;
|
return Font;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
var ErrorFont = (function ErrorFontClosure() {
|
||||||
|
function ErrorFont(error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorFont.prototype = {
|
||||||
|
charsToGlyphs: function ErrorFont_charsToGlyphs() {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ErrorFont;
|
||||||
|
})();
|
||||||
|
|
||||||
var CallothersubrCmd = (function CallothersubrCmdClosure() {
|
var CallothersubrCmd = (function CallothersubrCmdClosure() {
|
||||||
function CallothersubrCmd(index) {
|
function CallothersubrCmd(index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
Loading…
Reference in New Issue
Block a user