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

Add Encodings.js and change the code to generate a CharSet per font, this will allow future changes to the OpenType font generator

This commit is contained in:
Vivien Nicolas 2011-06-15 05:40:54 +02:00
parent 1dcd42b66c
commit f7e90f569c
4 changed files with 1584 additions and 34 deletions

19
test.js
View file

@ -93,17 +93,34 @@ function displayPage(num) {
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"));
var charset = [];
for (var j = 0; j < widths.length; j++) {
var index = widths[j];
if (index)
charset.push(encoding[j + firstchar]);
}
}
}
var subtype = fontDict.get("Subtype").name;
new Font(fontName, fontFile, encodingMap, subtype);
new Font(fontName, fontFile, encodingMap, charset, subtype);
return fontsReady = false;
} else if (font.loading) {
return fontsReady = false;