From ab3107e8e0df30f2006fca6881aebb3730f5fd63 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Thu, 1 Mar 2012 22:01:39 -0600 Subject: [PATCH] Optimization --- src/fonts.js | 48 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/src/fonts.js b/src/fonts.js index 0d0e12fec..df0acbbc5 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1966,51 +1966,11 @@ var Font = (function FontClosure() { } if (glyphName in GlyphsUnicode) { var unicode = GlyphsUnicode[glyphName]; - if (!unicode || reverseMap[unicode] === i) - continue; // unknown glyph name or in its own place + if (!unicode || (unicode in reverseMap)) + continue; // unknown glyph name or its place is taken - var destination = reverseMap[unicode]; - if (typeof destination === 'number' && destination > i) - continue; - - var j = i; - // Flipping unicodes while next destination unicode has assigned - // glyph and future glyph can be assigned to unicode. - while (typeof destination === 'number') { - glyphs[j].unicode = unicode; - reverseMap[unicode] = j; - if (changeCode) { - toFontChar[code] = unicode; - changeCode = false; - } - - code = glyphs[destination].unicode; - gid = ids[destination]; - glyphName = glyphNames[gid]; - if (!glyphName) { - glyphName = differences[code] || encoding[code]; - changeCode = true; - } - - unicode = GlyphsUnicode[glyphName]; - if (!unicode || reverseMap[unicode] === j) { - unicode = 0; - break; // unknown glyph name or in its own place - } - - j = destination; - destination = reverseMap[unicode]; - } - - if (!unicode) { - // Future glyph cannot be assigned to unicode, generate new one. - while (reverseMap[unusedUnicode]) - unusedUnicode++; - unicode = unusedUnicode++; - } - - glyphs[j].unicode = unicode; - reverseMap[unicode] = j; + glyphs[i].unicode = unicode; + reverseMap[unicode] = i; if (changeCode) toFontChar[code] = unicode; }