From 59c4ba0fb9943377d28b9e21d0851ce96221cfb1 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Wed, 31 Aug 2011 23:26:34 +0200 Subject: [PATCH] Fix for issue #418 --- fonts.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fonts.js b/fonts.js index 02aa52601..adf0a48e3 100755 --- a/fonts.js +++ b/fonts.js @@ -2208,21 +2208,28 @@ var Type2CFF = (function() { var charstrings = []; var differences = properties.differences; - var index = 0; + var index = 0, code = 0; var kCmapGlyphOffset = 0xE000; for (var i = 1; i < charsets.length; i++) { var glyph = charsets[i]; - for (var j = index; j < differences.length; j++) { - if (differences[j]) { - index = j; - break; + if (differences.length) { + for (var j = index; j < differences.length; j++) { + if (differences[j]) { + index = j; + break; + } } + + code = differences.indexOf(glyph); + if (code == -1) + code = properties.glyphs[glyph] || index; + } else { + code = GlyphsUnicode[glyph] || index; + index = code; } - var code = differences.indexOf(glyph); - if (code == -1) - code = properties.glyphs[glyph] || index; - + if (!code) + continue; var width = widths[code] || defaultWidth; properties.encoding[index] = index + kCmapGlyphOffset; charstrings.push({unicode: code + kCmapGlyphOffset, width: width, gid: i});