1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-28 23:28:16 +02:00

Merge branch 'master' of github.com:andreasgal/pdf.js

This commit is contained in:
sbarman 2011-06-17 12:14:45 -07:00
commit 70e6f493b1
3 changed files with 140 additions and 155 deletions

82
pdf.js
View file

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