Fixes the special char codes... and unpack fix

This commit is contained in:
notmasteryet 2011-09-28 21:34:24 -05:00
parent ab391c318d
commit 6403c91cbb

View File

@ -1424,15 +1424,17 @@ var Font = (function Font() {
return; return;
encoding[0] = { unicode: 0, width: 0 }; encoding[0] = { unicode: 0, width: 0 };
var glyph = 1, i, j; var glyph = 1, i, j, k;
for (i = 0; i < cidToUnicode.length; ++i) { for (i = 0; i < cidToUnicode.length; ++i) {
var unicode = cidToUnicode[i]; var unicode = cidToUnicode[i];
if (isArray(unicode)) { if (isArray(unicode)) {
var length = unicode.length;
if (glyph in glyphsWidths) { if (glyph in glyphsWidths) {
var length = unicode.length;
for (j = 0; j < length; j++) { for (j = 0; j < length; j++) {
encoding[unicode[j]] = { k = unicode[i];
unicode: unicode[j], encoding[k] = {
unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
k + kCmapGlyphOffset : k,
width: glyphsWidths[glyph] width: glyphsWidths[glyph]
}; };
} }
@ -1441,25 +1443,29 @@ var Font = (function Font() {
} else if (typeof unicode === 'object') { } else if (typeof unicode === 'object') {
var fillLength = unicode.f; var fillLength = unicode.f;
if (fillLength) { if (fillLength) {
unicode = unicode.c; k = unicode.c;
for (j = 0; j < fillLength; ++j) { for (j = 0; j < fillLength; ++j) {
if (!(glyph in glyphsWidths)) if (!(glyph in glyphsWidths))
continue; continue;
encoding[unicode] = { encoding[k] = {
unicode: unicode, unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
k + kCmapGlyphOffset : k,
width: glyphsWidths[glyph] width: glyphsWidths[glyph]
}; };
unicode++; k++;
glyph++; glyph++;
} }
} else } else
glyph += unicode.s; glyph += unicode.s;
} else if (unicode) { } else if (unicode && (glyph in glyphsWidths)) {
encoding[unicode] = { k = unicode;
unicode: unicode, encoding[k] = {
unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
k + kCmapGlyphOffset : k,
width: glyphsWidths[glyph++] width: glyphsWidths[glyph++]
}; };
} } else
glyph++;
} }
}, },