Fixes cmap sanitizer fro #215

This commit is contained in:
Yury Delendik 2013-01-31 16:13:36 -05:00
parent 1a78fa1b61
commit e5a6246f70

View File

@ -2409,6 +2409,10 @@ var Font = (function FontClosure() {
// Repair the TrueType file. It is can be damaged in the point of
// view of the sanitizer
data = this.checkAndRepair(name, file, properties);
if (!data) {
// TrueType data is not found, e.g. when the font is an OpenType font
warn('Font is not a TrueType font');
}
break;
default:
@ -3696,6 +3700,8 @@ var Font = (function FontClosure() {
prep = table;
else if (table.tag == 'cvt ')
cvt = table;
else if (table.tag == 'CFF ')
return null; // XXX: OpenType font is found, stopping
else // skipping table if it's not a required or optional table
continue;
}
@ -5257,6 +5263,7 @@ Type1Font.prototype = {
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
properties) {
var charstrings = [];
var usedUnicodes = [];
var i, length, glyphName;
var unusedUnicode = CMAP_GLYPH_OFFSET;
for (i = 0, length = glyphs.length; i < length; i++) {
@ -5264,6 +5271,10 @@ Type1Font.prototype = {
var glyphName = item.glyph;
var unicode = glyphName in GlyphsUnicode ?
GlyphsUnicode[glyphName] : unusedUnicode++;
while (usedUnicodes[unicode]) {
unicode = unusedUnicode++;
}
usedUnicodes[unicode] = true;
charstrings.push({
glyph: glyphName,
unicode: unicode,