Created
February 22, 2013 21:34
-
-
Save yurydelendik/5016733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js | |
index acf7951..cb0bff7 100644 | |
--- a/browser/extensions/pdfjs/content/build/pdf.js | |
+++ b/browser/extensions/pdfjs/content/build/pdf.js | |
@@ -20432,17 +20432,17 @@ Type1Font.prototype = { | |
} | |
}; | |
var CFFFont = (function CFFFontClosure() { | |
function CFFFont(file, properties) { | |
this.properties = properties; | |
var parser = new CFFParser(file, properties); | |
- var cff = parser.parse(true); | |
+ var cff = parser.parse(); | |
var compiler = new CFFCompiler(cff); | |
this.readExtra(cff); | |
try { | |
this.data = compiler.compile(); | |
} catch (e) { | |
warn('Failed to compile font ' + properties.loadedName); | |
// There may have just been an issue with the compiler, set the data | |
// anyway and hope the font loaded. | |
@@ -20597,17 +20597,17 @@ var CFFParser = (function CFFParserClosure() { | |
{ id: 'flex1', min: 11, resetStack: true } | |
]; | |
function CFFParser(file, properties) { | |
this.bytes = file.getBytes(); | |
this.properties = properties; | |
} | |
CFFParser.prototype = { | |
- parse: function CFFParser_parse(normalizeCIDData) { | |
+ parse: function CFFParser_parse() { | |
var properties = this.properties; | |
var cff = new CFF(); | |
this.cff = cff; | |
// The first five sections must be in order, all the others are reached | |
// via offsets contained in one of the below. | |
var header = this.parseHeader(); | |
var nameIndex = this.parseIndex(header.endPos); | |
@@ -20665,33 +20665,16 @@ var CFFParser = (function CFFParserClosure() { | |
cff.charStrings.count, cff.strings, false); | |
encoding = this.parseEncoding(topDict.getByName('Encoding'), | |
properties, | |
cff.strings, charset.charset); | |
} | |
cff.charset = charset; | |
cff.encoding = encoding; | |
- if (!cff.isCIDFont || !normalizeCIDData) | |
- return cff; | |
- | |
- // DirectWrite does not like CID fonts data. Trying to convert/flatten | |
- // the font data and remove CID properties. | |
- if (cff.fdArray.length !== 1) { | |
- warn('Unable to normalize CID font in CFF data -- using font as is'); | |
- return cff; | |
- } | |
- | |
- var fontDict = cff.fdArray[0]; | |
- fontDict.setByKey(17, topDict.getByName('CharStrings')); | |
- cff.topDict = fontDict; | |
- cff.isCIDFont = false; | |
- delete cff.fdArray; | |
- delete cff.fdSelect; | |
- | |
return cff; | |
}, | |
parseHeader: function CFFParser_parseHeader() { | |
var bytes = this.bytes; | |
var offset = 0; | |
while (bytes[offset] != 1) | |
++offset; | |
@@ -21312,19 +21295,22 @@ var CFFTopDict = (function CFFTopDictClosure() { | |
[[12, 21], 'PostScript', 'sid', null], | |
[[12, 22], 'BaseFontName', 'sid', null], | |
[[12, 23], 'BaseFontBlend', 'delta', null], | |
[[12, 31], 'CIDFontVersion', 'num', 0], | |
[[12, 32], 'CIDFontRevision', 'num', 0], | |
[[12, 33], 'CIDFontType', 'num', 0], | |
[[12, 34], 'CIDCount', 'num', 8720], | |
[[12, 35], 'UIDBase', 'num', null], | |
- [[12, 36], 'FDArray', 'offset', null], | |
+ // XXX: CID Fonts on DirectWrite 6.1 only seem to work if FDSelect comes | |
+ // before FDArray. | |
[[12, 37], 'FDSelect', 'offset', null], | |
- [[12, 38], 'FontName', 'sid', null]]; | |
+ [[12, 36], 'FDArray', 'offset', null], | |
+ [[12, 38], 'FontName', 'sid', null] | |
+ ]; | |
var tables = null; | |
function CFFTopDict(strings) { | |
if (tables === null) | |
tables = CFFDict.createTables(layout); | |
CFFDict.call(this, tables, strings); | |
this.privateDict = null; | |
} | |
CFFTopDict.prototype = Object.create(CFFDict.prototype); | |
@@ -21485,17 +21471,19 @@ var CFFCompiler = (function CFFCompilerClosure() { | |
// Compile the five entries that must be in order. | |
var header = this.compileHeader(cff.header); | |
output.add(header); | |
var nameIndex = this.compileNameIndex(cff.names); | |
output.add(nameIndex); | |
- var compiled = this.compileTopDicts([cff.topDict], output.length); | |
+ var compiled = this.compileTopDicts([cff.topDict], | |
+ output.length, | |
+ cff.isCIDFont); | |
output.add(compiled.output); | |
var topDictTracker = compiled.trackers[0]; | |
var stringIndex = this.compileStringIndex(cff.strings.strings); | |
output.add(stringIndex); | |
var globalSubrIndex = this.compileIndex(cff.globalSubrIndex); | |
output.add(globalSubrIndex); | |
@@ -21528,18 +21516,19 @@ var CFFCompiler = (function CFFCompilerClosure() { | |
output.add(charStrings); | |
if (cff.isCIDFont) { | |
// For some reason FDSelect must be in front of FDArray on windows. OSX | |
// and linux don't seem to care. | |
topDictTracker.setEntryLocation('FDSelect', [output.length], output); | |
var fdSelect = this.compileFDSelect(cff.fdSelect.raw); | |
output.add(fdSelect); | |
- | |
- var compiled = this.compileTopDicts(cff.fdArray, output.length); | |
+ // It is unclear if the sub font dictionary can have CID related | |
+ // dictionary keys, but the sanitizer doesn't like them so remove them. | |
+ var compiled = this.compileTopDicts(cff.fdArray, output.length, true); | |
topDictTracker.setEntryLocation('FDArray', [output.length], output); | |
output.add(compiled.output); | |
var fontDictTrackers = compiled.trackers; | |
this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output); | |
} | |
this.compilePrivateDicts([cff.topDict], [topDictTracker], output); | |
@@ -21615,21 +21604,30 @@ var CFFCompiler = (function CFFCompilerClosure() { | |
]; | |
}, | |
compileNameIndex: function CFFCompiler_compileNameIndex(names) { | |
var nameIndex = new CFFIndex(); | |
for (var i = 0, ii = names.length; i < ii; ++i) | |
nameIndex.add(stringToArray(names[i])); | |
return this.compileIndex(nameIndex); | |
}, | |
- compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length) { | |
+ compileTopDicts: function CFFCompiler_compileTopDicts(dicts, | |
+ length, | |
+ removeCidKeys) { | |
var fontDictTrackers = []; | |
var fdArrayIndex = new CFFIndex(); | |
for (var i = 0, ii = dicts.length; i < ii; ++i) { | |
var fontDict = dicts[i]; | |
+ if (removeCidKeys) { | |
+ fontDict.removeByName('CIDFontVersion'); | |
+ fontDict.removeByName('CIDFontRevision'); | |
+ fontDict.removeByName('CIDFontType'); | |
+ fontDict.removeByName('CIDCount'); | |
+ fontDict.removeByName('UIDBase'); | |
+ } | |
var fontDictTracker = new CFFOffsetTracker(); | |
var fontDictData = this.compileDict(fontDict, fontDictTracker); | |
fontDictTrackers.push(fontDictTracker); | |
fdArrayIndex.add(fontDictData); | |
fontDictTracker.offset(length); | |
} | |
fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers); | |
return { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment