final fix for issue #215

This commit is contained in:
sbarman 2011-08-23 18:33:17 -07:00
parent 5499cbc1b0
commit 51fa9f579c

24
pdf.js
View File

@ -4176,6 +4176,7 @@ var PartialEvaluator = (function() {
} }
var encodingMap = {}; var encodingMap = {};
var glyphMap = {};
var charset = []; var charset = [];
if (compositeFont) { if (compositeFont) {
// Special CIDFont support // Special CIDFont support
@ -4258,19 +4259,20 @@ var PartialEvaluator = (function() {
for (var i = 0, ii = length; i < ii; ++i) { for (var i = 0, ii = length; i < ii; ++i) {
var diffGlyph = diffEncoding[i]; var diffGlyph = diffEncoding[i];
var baseGlyph = baseEncoding[i]; var baseGlyph = baseEncoding[i];
if (diffGlyph) if (diffGlyph) {
glyphMap[i] = diffGlyph;
encodingMap[i] = GlyphsUnicode[diffGlyph]; encodingMap[i] = GlyphsUnicode[diffGlyph];
else if (baseGlyph) } else if (baseGlyph) {
glyphMap[i] = baseGlyph;
encodingMap[i] = GlyphsUnicode[baseGlyph]; encodingMap[i] = GlyphsUnicode[baseGlyph];
} }
}
if (fontDict.has('ToUnicode') && false) { if (fontDict.has('ToUnicode')) {
encodingMap = {empty: true};
var cmapObj = xref.fetchIfRef(fontDict.get('ToUnicode')); var cmapObj = xref.fetchIfRef(fontDict.get('ToUnicode'));
if (IsName(cmapObj)) { if (IsName(cmapObj)) {
error('ToUnicode file cmap translation not implemented'); error('ToUnicode file cmap translation not implemented');
} else if (IsStream(cmapObj)) { } else if (IsStream(cmapObj)) {
var encoding = Encodings['WinAnsiEncoding'];
var firstChar = xref.fetchIfRef(fontDict.get('FirstChar')); var firstChar = xref.fetchIfRef(fontDict.get('FirstChar'));
var tokens = []; var tokens = [];
@ -4279,7 +4281,8 @@ var PartialEvaluator = (function() {
var cmap = cmapObj.getBytes(cmapObj.length); var cmap = cmapObj.getBytes(cmapObj.length);
for (var i = 0; i < cmap.length; i++) { for (var i = 0; i < cmap.length; i++) {
var byte = cmap[i]; var byte = cmap[i];
if (byte == 0x20 || byte == 0x0A || byte == 0x3C || byte == 0x3E) { if (byte == 0x20 || byte == 0x0A || byte == 0x3C ||
byte == 0x3E) {
switch (token) { switch (token) {
case 'useCMap': case 'useCMap':
error('useCMap is not implemented'); error('useCMap is not implemented');
@ -4301,10 +4304,6 @@ var PartialEvaluator = (function() {
var startRange = parseInt('0x' + tokens[j]); var startRange = parseInt('0x' + tokens[j]);
var endRange = parseInt('0x' + tokens[j + 1]); var endRange = parseInt('0x' + tokens[j + 1]);
var code = parseInt('0x' + tokens[j + 2]); var code = parseInt('0x' + tokens[j + 2]);
for (var k = startRange; k <= endRange; k++) {
charset.push(encoding[code++] || '.notdef');
}
} }
break; break;
@ -4312,8 +4311,7 @@ var PartialEvaluator = (function() {
for (var j = 0; j < tokens.length; j += 2) { for (var j = 0; j < tokens.length; j += 2) {
var index = parseInt('0x' + tokens[j]); var index = parseInt('0x' + tokens[j]);
var code = parseInt('0x' + tokens[j + 1]); var code = parseInt('0x' + tokens[j + 1]);
encodingMap[index] = GlyphsUnicode[encoding[code]]; encodingMap[index] = code;
charset.push(encoding[code] || '.notdef');
} }
break; break;
@ -4339,7 +4337,7 @@ var PartialEvaluator = (function() {
var widths = xref.fetchIfRef(fontDict.get('Widths')) || []; var widths = xref.fetchIfRef(fontDict.get('Widths')) || [];
for (var j = 0; j < widths.length; j++) { for (var j = 0; j < widths.length; j++) {
if (widths[j]) if (widths[j])
charset.push(encodingMap[j + firstChar]); charset.push(glyphMap[j + firstChar]);
} }
} }