|
|
@ -1729,52 +1729,57 @@ var CanvasGraphics = (function() { |
|
|
|
var fontName = descriptor.get("FontName").name; |
|
|
|
var fontName = descriptor.get("FontName").name; |
|
|
|
fontName = fontName.replace("+", "_"); |
|
|
|
fontName = fontName.replace("+", "_"); |
|
|
|
|
|
|
|
|
|
|
|
var font = Fonts[fontName]; |
|
|
|
var fontFile = descriptor.get2("FontFile", "FontFile2"); |
|
|
|
if (!font) { |
|
|
|
if (!fontFile) |
|
|
|
var fontFile = descriptor.get2("FontFile", "FontFile2"); |
|
|
|
errort("FontFile not found for font: " + fontName); |
|
|
|
fontFile = xref.fetchIfRef(fontFile); |
|
|
|
fontFile = xref.fetchIfRef(fontFile); |
|
|
|
|
|
|
|
|
|
|
|
// Generate the custom cmap of the font if needed
|
|
|
|
// Generate the custom cmap of the font if needed
|
|
|
|
var encodingMap = {}; |
|
|
|
var encodingMap = {}; |
|
|
|
if (fontDict.has("Encoding")) { |
|
|
|
if (fontDict.has("Encoding")) { |
|
|
|
|
|
|
|
var encoding = xref.fetchIfRef(fontDict.get("Encoding")); |
|
|
|
var encoding = xref.fetchIfRef(fontDict.get("Encoding")); |
|
|
|
if (IsDict(encoding)) { |
|
|
|
if (IsDict(encoding)) { |
|
|
|
// Build an map between codes and glyphs
|
|
|
|
// Build an map between codes and glyphs
|
|
|
|
var differences = encoding.get("Differences"); |
|
|
|
var differences = encoding.get("Differences"); |
|
|
|
var index = 0; |
|
|
|
var index = 0; |
|
|
|
for (var j = 0; j < differences.length; j++) { |
|
|
|
for (var j = 0; j < differences.length; j++) { |
|
|
|
var data = differences[j]; |
|
|
|
var data = differences[j]; |
|
|
|
IsNum(data) ? index = data : encodingMap[index++] = data; |
|
|
|
IsNum(data) ? index = data : encodingMap[index++] = data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get the font charset if any
|
|
|
|
// Get the font charset
|
|
|
|
var charset = descriptor.get("CharSet"); |
|
|
|
var charset = descriptor.get("CharSet").split("/"); |
|
|
|
if (charset) |
|
|
|
|
|
|
|
charset = charset.split("/"); |
|
|
|
} else if (IsName(encoding)) { |
|
|
|
|
|
|
|
var encoding = Encodings[encoding]; |
|
|
|
} else if (IsName(encoding)) { |
|
|
|
var widths = xref.fetchIfRef(fontDict.get("Widths")); |
|
|
|
var encoding = Encodings[encoding]; |
|
|
|
var firstchar = xref.fetchIfRef(fontDict.get("FirstChar")); |
|
|
|
var widths = xref.fetchIfRef(fontDict.get("Widths")); |
|
|
|
|
|
|
|
var firstchar = xref.fetchIfRef(fontDict.get("FirstChar")); |
|
|
|
var charset = []; |
|
|
|
|
|
|
|
for (var j = 0; j < widths.length; j++) { |
|
|
|
var charset = []; |
|
|
|
var index = widths[j]; |
|
|
|
for (var j = 0; j < widths.length; j++) { |
|
|
|
if (!index) |
|
|
|
var index = widths[j]; |
|
|
|
continue; |
|
|
|
if (!index) |
|
|
|
charset.push(encoding[j + firstchar]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
charset.push(encoding[j + firstchar]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var properties = { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var properties = { |
|
|
|
type: fontDict.get("Subtype").name, |
|
|
|
type: fontDict.get("Subtype").name, |
|
|
|
encoding: encodingMap, |
|
|
|
encoding: encodingMap, |
|
|
|
charset: charset, |
|
|
|
charset: charset, |
|
|
|
bbox: descriptor.get("FontBBox") |
|
|
|
bbox: descriptor.get("FontBBox") |
|
|
|
}; |
|
|
|
}; |
|
|
|
new Font(fontName, fontFile, properties); |
|
|
|
|
|
|
|
} |
|
|
|
return { |
|
|
|
return Fonts[fontName]; |
|
|
|
name: fontName, |
|
|
|
|
|
|
|
file: fontFile, |
|
|
|
|
|
|
|
properties: properties |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
beginDrawing: function(mediaBox) { |
|
|
|
beginDrawing: function(mediaBox) { |
|
|
|