} else {
// parsing hex UTF-16BE numbers
var str = [];
- for (var i = 0, ii = token.length; i < ii; i += 4)
- str.push(parseInt(token.substr(i, 4), 16));
+ for (var k = 0, kk = token.length; k < kk; k += 4) {
+ var b = parseInt(token.substr(k, 4), 16);
+ if (b <= 0x10) {
+ k += 4;
+ b = (b << 16) | parseInt(token.substr(k, 4), 16);
+ b -= 0x10000;
+ str.push(0xD800 | (b >> 10));
+ str.push(0xDC00 | (b & 0x3FF));
+ break;
+ }
+ str.push(b);
+ }
tokens.push(String.fromCharCode.apply(String, str));
token = '';
}
else
this.rebuildToUnicode(properties);
+ this.toUnicodeOriginal = this.toUnicode.slice();
+ for (var i = 0, j = 0xE000; i < this.toUnicode.length; i++) {
+ if (typeof this.toUnicode[i] == 'number')
+ break;
+ this.toUnicode[i] = j++;
+ }
+
if (!file) {
// The file data is not specified. Trying to fix the font name
// to be used with the canvas.font.
for (var i = 1; i < numGlyphs; i++) {
var cid = gidToCidMap[i] || i;
var unicode = this.toUnicode[cid];
- if (!unicode || isSpecialUnicode(unicode) ||
+ if (!unicode || typeof unicode !== 'number' || isSpecialUnicode(unicode) ||
unicode in usedUnicodes) {
unassignedUnicodeItems.push(i);
continue;
var usedUnicodes = [], unassignedUnicodeItems = [];
for (var i = 0, ii = glyphs.length; i < ii; i++) {
var unicode = toUnicode[i + 1];
- if (!unicode || unicode in usedUnicodes) {
+ if (!unicode || typeof unicode !== 'number' || unicode in usedUnicodes) {
unassignedUnicodeItems.push(i);
continue;
}
}
properties.baseEncoding = encoding;
}
- if (properties.subtype == 'CIDFontType0C') {
+ if (false && properties.subtype == 'CIDFontType0C') {
var toUnicode = [];
for (var i = 0; i < charstrings.length; ++i) {
var charstring = charstrings[i];
break;
}
- var unicodeChars = !('toUnicode' in this) ? charcode :
- this.toUnicode[charcode] || charcode;
+ var unicodeChars = !('toUnicodeOriginal' in this) ? charcode :
+ this.toUnicodeOriginal[charcode] || charcode;
if (typeof unicodeChars === 'number')
unicodeChars = String.fromCharCode(unicodeChars);