|
|
@ -64,14 +64,6 @@ function stringToBytes(str) { |
|
|
|
return bytes; |
|
|
|
return bytes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function singleByteToMultiByteString (str) { |
|
|
|
|
|
|
|
var multiByteStr = ""; |
|
|
|
|
|
|
|
var bytes = stringToBytes(e); |
|
|
|
|
|
|
|
for (var j = 0; j<bytes.length; j++) { |
|
|
|
|
|
|
|
multiByteStr += String.fromCharCode((bytes[j++]<<16) | bytes[j]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return multiByteStr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var Stream = (function() { |
|
|
|
var Stream = (function() { |
|
|
|
function constructor(arrayBuffer, start, length, dict) { |
|
|
|
function constructor(arrayBuffer, start, length, dict) { |
|
|
|
this.bytes = new Uint8Array(arrayBuffer); |
|
|
|
this.bytes = new Uint8Array(arrayBuffer); |
|
|
@ -3635,16 +3627,22 @@ var PartialEvaluator = (function() { |
|
|
|
var fd; |
|
|
|
var fd; |
|
|
|
var descendant = []; |
|
|
|
var descendant = []; |
|
|
|
var subType = fontDict.get('Subtype'); |
|
|
|
var subType = fontDict.get('Subtype'); |
|
|
|
|
|
|
|
var compositeFont = false; |
|
|
|
assertWellFormed(IsName(subType), 'invalid font Subtype'); |
|
|
|
assertWellFormed(IsName(subType), 'invalid font Subtype'); |
|
|
|
|
|
|
|
|
|
|
|
//If font is a composite get the FontDescriptor from the descendant font
|
|
|
|
//If font is a composite
|
|
|
|
if (subType.name == "Type0") |
|
|
|
// - get the descendant font
|
|
|
|
|
|
|
|
// - set the type according to the descendant font
|
|
|
|
|
|
|
|
// - get the FontDescriptor from the descendant font
|
|
|
|
|
|
|
|
if (subType.name == 'Type0') |
|
|
|
{ |
|
|
|
{ |
|
|
|
var df = fontDict.get("DescendantFonts"); |
|
|
|
var df = fontDict.get('DescendantFonts'); |
|
|
|
if (!df) |
|
|
|
if (!df) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
compositeFont = true; |
|
|
|
descendant = xref.fetch(df[0]); |
|
|
|
descendant = xref.fetch(df[0]); |
|
|
|
fd = descendant.get("FontDescriptor"); |
|
|
|
subType = descendant.get('Subtype'); |
|
|
|
|
|
|
|
fd = descendant.get('FontDescriptor'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fd = fontDict.get('FontDescriptor'); |
|
|
|
fd = fontDict.get('FontDescriptor'); |
|
|
|
} |
|
|
|
} |
|
|
@ -3665,24 +3663,26 @@ var PartialEvaluator = (function() { |
|
|
|
|
|
|
|
|
|
|
|
var encodingMap = {}; |
|
|
|
var encodingMap = {}; |
|
|
|
var charset = []; |
|
|
|
var charset = []; |
|
|
|
if (subType.name == 'Type0') { |
|
|
|
if (compositeFont) { |
|
|
|
//XXX CIDFont support - only identity CID Encoding for now
|
|
|
|
//Special CIDFont support
|
|
|
|
|
|
|
|
//XXX only identity CID Encodings supported for now
|
|
|
|
var encoding = xref.fetchIfRef(fontDict.get('Encoding')); |
|
|
|
var encoding = xref.fetchIfRef(fontDict.get('Encoding')); |
|
|
|
if (IsName(encoding)) { |
|
|
|
if (IsName(encoding)) { |
|
|
|
//Encoding is a predefined CMap
|
|
|
|
//Encoding is a predefined CMap
|
|
|
|
if (encoding.name == 'Identity-H') { |
|
|
|
if (encoding.name == 'Identity-H') { |
|
|
|
if (descendant.get('Subtype').name == 'CIDFontType2') |
|
|
|
if (subType.name == 'CIDFontType2') { |
|
|
|
{ |
|
|
|
var cidToGidMap = descendant.get('CIDToGIDMap'); |
|
|
|
//Extract an encoding from the CIDToGIDMap
|
|
|
|
if (cidToGidMap) { |
|
|
|
var glyphsStream = xref.fetchIfRef(descendant.get('CIDToGIDMap')); |
|
|
|
//Extract the charset from the CIDToGIDMap
|
|
|
|
var glyphsData = glyphsStream.getBytes(0); |
|
|
|
var glyphsStream = xref.fetchIfRef(cidToGidMap); |
|
|
|
var i = 0; |
|
|
|
var glyphsData = glyphsStream.getBytes(0); |
|
|
|
for (var j=0; j<glyphsData.length; j++) { |
|
|
|
var i = 0; |
|
|
|
var glyphID = (glyphsData[j++]*0x100)+glyphsData[j]; |
|
|
|
//glyph ids are big-endian 2-byte values
|
|
|
|
//encodingMap[glyphID] = i++;
|
|
|
|
for (var j=0; j<glyphsData.length; j++) { |
|
|
|
charset.push(glyphID); |
|
|
|
var glyphID = (glyphsData[j++] << 8) | glyphsData[j]; |
|
|
|
|
|
|
|
charset.push(glyphID); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
encoding[0] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
TODO ('Need to support predefined CMaps see PDF 32000-1:2008 9.7.5.2 Predefined CMaps') |
|
|
|
TODO ('Need to support predefined CMaps see PDF 32000-1:2008 9.7.5.2 Predefined CMaps') |
|
|
@ -3820,7 +3820,8 @@ var PartialEvaluator = (function() { |
|
|
|
flags: descriptor.get('Flags'), |
|
|
|
flags: descriptor.get('Flags'), |
|
|
|
italicAngle: descriptor.get('ItalicAngle'), |
|
|
|
italicAngle: descriptor.get('ItalicAngle'), |
|
|
|
fixedPitch: false, |
|
|
|
fixedPitch: false, |
|
|
|
textMatrix: IDENTITY_MATRIX |
|
|
|
textMatrix: IDENTITY_MATRIX, |
|
|
|
|
|
|
|
compositeFont: compositeFont |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|