Merge pull request #443 from vingtetun/master

Partial fix for issue #440
This commit is contained in:
notmasteryet 2011-09-06 16:14:48 -07:00
commit 122e4c1e67
2 changed files with 43 additions and 2 deletions

View File

@ -857,9 +857,47 @@ var Font = (function Font() {
});
}
// Check that table are sorted by platformID then encodingID,
records.sort(function(a, b) {
return ((a.platformID << 16) + a.encodingID) -
((b.platformID << 16) + b.encodingID)
});
var tables = [records[0]];
for (var i = 1; i < numRecords; i++) {
// The sanitizer will drop the font if 2 tables have the same
// platformID and the same encodingID, this will be correct for
// most cases but if the font has been made for Mac it could
// exist a few platformID: 1, encodingID: 0 but with a different
// language field and that's correct. But the sanitizer does not
// seem to support this case.
var current = records[i];
var previous = records[i - 1];
if (((current.platformID << 16) + current.encodingID) <=
((previous.platformID << 16) + previous.encodingID))
continue;
tables.push(current);
}
var missing = numRecords - tables.length;
if (missing) {
numRecords = tables.length;
var data = string16(version) + string16(numRecords);
for (var i = 0; i < numRecords; i++) {
var table = tables[i];
data += string16(table.platformID) +
string16(table.encodingID) +
string32(table.offset);
}
for (var i = 0; i < data.length; i++)
cmap.data[i] = data.charCodeAt(i);
}
var encoding = properties.encoding;
for (var i = 0; i < numRecords; i++) {
var table = records[i];
var table = tables[i];
font.pos = start + table.offset;
var format = int16(font.getBytes(2));

5
pdf.js
View File

@ -4304,6 +4304,9 @@ var PartialEvaluator = (function() {
var index = GlyphsUnicode[glyph] || i;
glyphsMap[glyph] = encodingMap[i] = index;
if (!fontFile)
continue;
if (index <= 0x1f || (index >= 127 && index <= 255))
glyphsMap[glyph] = encodingMap[i] += kCmapGlyphOffset;
}
@ -4824,7 +4827,7 @@ var CanvasGraphics = (function() {
(fontObj.bold ? 'bold' : 'normal');
var italic = fontObj.italic ? 'italic' : 'normal';
var rule = italic + ' ' + bold + ' ' + size + 'px "' + name + '"';
var rule = italic + ' ' + bold + ' ' + size + 'px "' + name + '", "sans-serif"';
this.ctx.font = rule;
}
},