Lazify GlyphsUnicode.
This commit is contained in:
parent
58329f7f92
commit
4ef20de429
@ -31,7 +31,7 @@ var Util = sharedUtil.Util;
|
||||
var bytesToString = sharedUtil.bytesToString;
|
||||
var error = sharedUtil.error;
|
||||
var Stream = coreStream.Stream;
|
||||
var GlyphsUnicode = coreGlyphList.GlyphsUnicode;
|
||||
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
|
||||
|
||||
var coreFonts; // see _setCoreFonts below
|
||||
var CFFParser; // = coreFonts.CFFParser;
|
||||
@ -670,7 +670,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
this.gsubrs = cffInfo.gsubrs || [];
|
||||
this.subrs = cffInfo.subrs || [];
|
||||
this.cmap = cmap;
|
||||
this.glyphNameMap = glyphNameMap || GlyphsUnicode;
|
||||
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
|
||||
|
||||
this.compiledGlyphs = [];
|
||||
this.gsubrsBias = (this.gsubrs.length < 1240 ?
|
||||
|
@ -56,8 +56,8 @@ var Stream = coreStream.Stream;
|
||||
var Lexer = coreParser.Lexer;
|
||||
var CMapFactory = coreCMap.CMapFactory;
|
||||
var IdentityCMap = coreCMap.IdentityCMap;
|
||||
var GlyphsUnicode = coreGlyphList.GlyphsUnicode;
|
||||
var DingbatsGlyphsUnicode = coreGlyphList.DingbatsGlyphsUnicode;
|
||||
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
|
||||
var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
|
||||
var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
|
||||
var ExpertCharset = coreCharsets.ExpertCharset;
|
||||
var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
|
||||
@ -2542,7 +2542,7 @@ var Font = (function FontClosure() {
|
||||
this.vmetrics = properties.vmetrics;
|
||||
this.defaultVMetrics = properties.defaultVMetrics;
|
||||
}
|
||||
|
||||
var glyphsUnicodeMap;
|
||||
if (!file || file.isEmpty) {
|
||||
if (file) {
|
||||
// Some bad PDF generators will include empty font files,
|
||||
@ -2591,35 +2591,37 @@ var Font = (function FontClosure() {
|
||||
this.toUnicode = new ToUnicodeMap(map);
|
||||
} else if (/Symbol/i.test(fontName)) {
|
||||
var symbols = Encodings.SymbolSetEncoding;
|
||||
glyphsUnicodeMap = getGlyphsUnicode();
|
||||
for (charCode in symbols) {
|
||||
fontChar = GlyphsUnicode[symbols[charCode]];
|
||||
fontChar = glyphsUnicodeMap[symbols[charCode]];
|
||||
if (!fontChar) {
|
||||
continue;
|
||||
}
|
||||
this.toFontChar[charCode] = fontChar;
|
||||
}
|
||||
for (charCode in properties.differences) {
|
||||
fontChar = GlyphsUnicode[properties.differences[charCode]];
|
||||
fontChar = glyphsUnicodeMap[properties.differences[charCode]];
|
||||
if (!fontChar) {
|
||||
continue;
|
||||
}
|
||||
this.toFontChar[charCode] = fontChar;
|
||||
}
|
||||
} else if (/Dingbats/i.test(fontName)) {
|
||||
glyphsUnicodeMap = getDingbatsGlyphsUnicode();
|
||||
if (/Wingdings/i.test(name)) {
|
||||
warn('Wingdings font without embedded font file, ' +
|
||||
'falling back to the ZapfDingbats encoding.');
|
||||
}
|
||||
var dingbats = Encodings.ZapfDingbatsEncoding;
|
||||
for (charCode in dingbats) {
|
||||
fontChar = DingbatsGlyphsUnicode[dingbats[charCode]];
|
||||
fontChar = glyphsUnicodeMap[dingbats[charCode]];
|
||||
if (!fontChar) {
|
||||
continue;
|
||||
}
|
||||
this.toFontChar[charCode] = fontChar;
|
||||
}
|
||||
for (charCode in properties.differences) {
|
||||
fontChar = DingbatsGlyphsUnicode[properties.differences[charCode]];
|
||||
fontChar = glyphsUnicodeMap[properties.differences[charCode]];
|
||||
if (!fontChar) {
|
||||
continue;
|
||||
}
|
||||
@ -2627,18 +2629,20 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
} else if (isStandardFont) {
|
||||
this.toFontChar = [];
|
||||
glyphsUnicodeMap = getGlyphsUnicode();
|
||||
for (charCode in properties.defaultEncoding) {
|
||||
glyphName = (properties.differences[charCode] ||
|
||||
properties.defaultEncoding[charCode]);
|
||||
this.toFontChar[charCode] = GlyphsUnicode[glyphName];
|
||||
this.toFontChar[charCode] = glyphsUnicodeMap[glyphName];
|
||||
}
|
||||
} else {
|
||||
var unicodeCharCode, notCidFont = (type.indexOf('CIDFontType') === -1);
|
||||
glyphsUnicodeMap = getGlyphsUnicode();
|
||||
this.toUnicode.forEach(function(charCode, unicodeCharCode) {
|
||||
if (notCidFont) {
|
||||
glyphName = (properties.differences[charCode] ||
|
||||
properties.defaultEncoding[charCode]);
|
||||
unicodeCharCode = (GlyphsUnicode[glyphName] || unicodeCharCode);
|
||||
unicodeCharCode = (glyphsUnicodeMap[glyphName] || unicodeCharCode);
|
||||
}
|
||||
this.toFontChar[charCode] = unicodeCharCode;
|
||||
}.bind(this));
|
||||
@ -4331,6 +4335,7 @@ var Font = (function FontClosure() {
|
||||
properties.baseEncodingName === 'WinAnsiEncoding') {
|
||||
baseEncoding = Encodings[properties.baseEncodingName];
|
||||
}
|
||||
var glyphsUnicodeMap = getGlyphsUnicode();
|
||||
for (charCode = 0; charCode < 256; charCode++) {
|
||||
var glyphName;
|
||||
if (this.differences && charCode in this.differences) {
|
||||
@ -4346,7 +4351,7 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
var unicodeOrCharCode, isUnicode = false;
|
||||
if (cmapPlatformId === 3 && cmapEncodingId === 1) {
|
||||
unicodeOrCharCode = GlyphsUnicode[glyphName];
|
||||
unicodeOrCharCode = glyphsUnicodeMap[glyphName];
|
||||
isUnicode = true;
|
||||
} else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
|
||||
// TODO: the encoding needs to be updated with mac os table.
|
||||
@ -4652,6 +4657,7 @@ var Font = (function FontClosure() {
|
||||
for (charcode in differences) {
|
||||
encoding[charcode] = differences[charcode];
|
||||
}
|
||||
var glyphsUnicodeMap = getGlyphsUnicode();
|
||||
for (charcode in encoding) {
|
||||
// a) Map the character code to a character name.
|
||||
var glyphName = encoding[charcode];
|
||||
@ -4659,7 +4665,7 @@ var Font = (function FontClosure() {
|
||||
// Bibliography) to obtain the corresponding Unicode value.
|
||||
if (glyphName === '') {
|
||||
continue;
|
||||
} else if (GlyphsUnicode[glyphName] === undefined) {
|
||||
} else if (glyphsUnicodeMap[glyphName] === undefined) {
|
||||
// (undocumented) c) Few heuristics to recognize unknown glyphs
|
||||
// NOTE: Adobe Reader does not do this step, but OSX Preview does
|
||||
var code = 0;
|
||||
@ -4690,7 +4696,7 @@ var Font = (function FontClosure() {
|
||||
var baseEncoding = Encodings[baseEncodingName];
|
||||
if (baseEncoding && (glyphName = baseEncoding[charcode])) {
|
||||
toUnicode[charcode] =
|
||||
String.fromCharCode(GlyphsUnicode[glyphName]);
|
||||
String.fromCharCode(glyphsUnicodeMap[glyphName]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -4698,7 +4704,8 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
toUnicode[charcode] = String.fromCharCode(GlyphsUnicode[glyphName]);
|
||||
toUnicode[charcode] =
|
||||
String.fromCharCode(glyphsUnicodeMap[glyphName]);
|
||||
}
|
||||
return new ToUnicodeMap(toUnicode);
|
||||
}
|
||||
@ -4766,7 +4773,8 @@ var Font = (function FontClosure() {
|
||||
width = this.widths[glyphName];
|
||||
break;
|
||||
}
|
||||
var glyphUnicode = GlyphsUnicode[glyphName];
|
||||
var glyphsUnicodeMap = getGlyphsUnicode();
|
||||
var glyphUnicode = glyphsUnicodeMap[glyphName];
|
||||
// finding the charcode via unicodeToCID map
|
||||
var charcode = 0;
|
||||
if (this.composite) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -347,6 +347,18 @@ function shadow(obj, prop, value) {
|
||||
}
|
||||
PDFJS.shadow = shadow;
|
||||
|
||||
function getLookupTableFactory(initializer) {
|
||||
var lookup;
|
||||
return function () {
|
||||
if (initializer) {
|
||||
lookup = Object.create(null);
|
||||
initializer(lookup);
|
||||
initializer = null;
|
||||
}
|
||||
return lookup;
|
||||
};
|
||||
}
|
||||
|
||||
var LinkTarget = PDFJS.LinkTarget = {
|
||||
NONE: 0, // Default value.
|
||||
SELF: 1,
|
||||
@ -2338,6 +2350,7 @@ exports.combineUrl = combineUrl;
|
||||
exports.createPromiseCapability = createPromiseCapability;
|
||||
exports.deprecated = deprecated;
|
||||
exports.error = error;
|
||||
exports.getLookupTableFactory = getLookupTableFactory;
|
||||
exports.info = info;
|
||||
exports.isArray = isArray;
|
||||
exports.isArrayBuffer = isArrayBuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user