From 6403c91cbb1d8823d26ffc54c2c99590ce7c3942 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Wed, 28 Sep 2011 21:34:24 -0500 Subject: [PATCH] Fixes the special char codes... and unpack fix --- fonts.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/fonts.js b/fonts.js index 22b6a6c99..3b4bfbd62 100644 --- a/fonts.js +++ b/fonts.js @@ -1424,15 +1424,17 @@ var Font = (function Font() { return; encoding[0] = { unicode: 0, width: 0 }; - var glyph = 1, i, j; + var glyph = 1, i, j, k; for (i = 0; i < cidToUnicode.length; ++i) { var unicode = cidToUnicode[i]; if (isArray(unicode)) { - var length = unicode.length; if (glyph in glyphsWidths) { + var length = unicode.length; for (j = 0; j < length; j++) { - encoding[unicode[j]] = { - unicode: unicode[j], + k = unicode[i]; + encoding[k] = { + unicode: k <= 0x1f || (k >= 127 && k <= 255) ? + k + kCmapGlyphOffset : k, width: glyphsWidths[glyph] }; } @@ -1441,25 +1443,29 @@ var Font = (function Font() { } else if (typeof unicode === 'object') { var fillLength = unicode.f; if (fillLength) { - unicode = unicode.c; + k = unicode.c; for (j = 0; j < fillLength; ++j) { if (!(glyph in glyphsWidths)) continue; - encoding[unicode] = { - unicode: unicode, + encoding[k] = { + unicode: k <= 0x1f || (k >= 127 && k <= 255) ? + k + kCmapGlyphOffset : k, width: glyphsWidths[glyph] }; - unicode++; + k++; glyph++; } } else glyph += unicode.s; - } else if (unicode) { - encoding[unicode] = { - unicode: unicode, + } else if (unicode && (glyph in glyphsWidths)) { + k = unicode; + encoding[k] = { + unicode: k <= 0x1f || (k >= 127 && k <= 255) ? + k + kCmapGlyphOffset : k, width: glyphsWidths[glyph++] }; - } + } else + glyph++; } },