1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Handle missing 'FontName' entry in FontDescriptor object

This commit is contained in:
mduan 2013-01-11 17:10:09 -08:00
parent e61b104852
commit fadcb71c21
4 changed files with 161 additions and 1 deletions

View file

@ -1146,10 +1146,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// a variant.
var firstChar = dict.get('FirstChar') || 0;
var lastChar = dict.get('LastChar') || maxCharIndex;
var fontName = descriptor.get('FontName');
var baseFont = baseDict.get('BaseFont');
// Some bad pdf's have a string as the font name.
if (isString(fontName))
if (isString(fontName)) {
fontName = new Name(fontName);
}
if (isString(baseFont)) {
baseFont = new Name(baseFont);
}
var fontNameStr = fontName && fontName.name;
var baseFontStr = baseFont && baseFont.name;
if (fontNameStr !== baseFontStr) {
warn('The FontDescriptor\'s FontName is "' + fontNameStr +
'" but should be the same as the Font\'s BaseFont "' +
baseFontStr + '"');
}
fontName = fontName || baseFont;
assertWellFormed(isName(fontName), 'invalid font name');
var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');