Optimization
This commit is contained in:
parent
38e3f32557
commit
ab3107e8e0
48
src/fonts.js
48
src/fonts.js
@ -1966,51 +1966,11 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
if (glyphName in GlyphsUnicode) {
|
if (glyphName in GlyphsUnicode) {
|
||||||
var unicode = GlyphsUnicode[glyphName];
|
var unicode = GlyphsUnicode[glyphName];
|
||||||
if (!unicode || reverseMap[unicode] === i)
|
if (!unicode || (unicode in reverseMap))
|
||||||
continue; // unknown glyph name or in its own place
|
continue; // unknown glyph name or its place is taken
|
||||||
|
|
||||||
var destination = reverseMap[unicode];
|
glyphs[i].unicode = unicode;
|
||||||
if (typeof destination === 'number' && destination > i)
|
reverseMap[unicode] = 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;
|
|
||||||
if (changeCode)
|
if (changeCode)
|
||||||
toFontChar[code] = unicode;
|
toFontChar[code] = unicode;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user