@@ -4110,18 +4110,28 @@ var Font = (function FontClosure() {
4110
4110
this .toFontChar = newMapping .toFontChar ;
4111
4111
var numGlyphs = font .numGlyphs ;
4112
4112
4113
- function getCharCode (charCodeToGlyphId , glyphId , addMap ) {
4113
+ function getCharCodes (charCodeToGlyphId , glyphId ) {
4114
+ var charCodes = null ;
4114
4115
for (var charCode in charCodeToGlyphId ) {
4115
4116
if (glyphId === charCodeToGlyphId [charCode ]) {
4116
- return charCode | 0 ;
4117
+ if (!charCodes ) {
4118
+ charCodes = [] ;
4119
+ }
4120
+ charCodes .push (charCode | 0 );
4117
4121
}
4118
4122
}
4119
- if (addMap ) {
4120
- newMapping .charCodeToGlyphId [newMapping .nextAvailableFontCharCode ] =
4121
- glyphId ;
4122
- return newMapping .nextAvailableFontCharCode ++;
4123
+ return charCodes ;
4124
+ }
4125
+
4126
+ function createCharCode (charCodeToGlyphId , glyphId ) {
4127
+ for (var charCode in charCodeToGlyphId ) {
4128
+ if (glyphId === charCodeToGlyphId [charCode ]) {
4129
+ return charCode | 0 ;
4130
+ }
4123
4131
}
4124
- return null ;
4132
+ newMapping .charCodeToGlyphId [newMapping .nextAvailableFontCharCode ] =
4133
+ glyphId ;
4134
+ return newMapping .nextAvailableFontCharCode ++;
4125
4135
}
4126
4136
4127
4137
var seacs = font .seacs ;
@@ -4144,24 +4154,27 @@ var Font = (function FontClosure() {
4144
4154
y : seac [0 ] * matrix [1 ] + seac [1 ] * matrix [3 ] + matrix [5 ]
4145
4155
};
4146
4156
4147
- var charCode = getCharCode (mapping , glyphId );
4148
- if (charCode === null ) {
4157
+ var charCodes = getCharCodes (mapping , glyphId );
4158
+ if (! charCodes ) {
4149
4159
// There's no point in mapping it if the char code was never mapped
4150
4160
// to begin with.
4151
4161
continue ;
4152
4162
}
4153
- // Find a fontCharCode that maps to the base and accent glyphs. If one
4154
- // doesn't exists, create it.
4155
- var charCodeToGlyphId = newMapping .charCodeToGlyphId ;
4156
- var baseFontCharCode = getCharCode (charCodeToGlyphId , baseGlyphId ,
4157
- true );
4158
- var accentFontCharCode = getCharCode (charCodeToGlyphId , accentGlyphId ,
4159
- true );
4160
- seacMap [charCode ] = {
4161
- baseFontCharCode : baseFontCharCode ,
4162
- accentFontCharCode : accentFontCharCode ,
4163
- accentOffset : accentOffset
4164
- };
4163
+ for (var i = 0 , ii = charCodes .length ; i < ii ; i ++) {
4164
+ var charCode = charCodes [i ];
4165
+ // Find a fontCharCode that maps to the base and accent glyphs.
4166
+ // If one doesn't exists, create it.
4167
+ var charCodeToGlyphId = newMapping .charCodeToGlyphId ;
4168
+ var baseFontCharCode = createCharCode (charCodeToGlyphId ,
4169
+ baseGlyphId );
4170
+ var accentFontCharCode = createCharCode (charCodeToGlyphId ,
4171
+ accentGlyphId );
4172
+ seacMap [charCode ] = {
4173
+ baseFontCharCode : baseFontCharCode ,
4174
+ accentFontCharCode : accentFontCharCode ,
4175
+ accentOffset : accentOffset
4176
+ };
4177
+ }
4165
4178
}
4166
4179
properties .seacMap = seacMap ;
4167
4180
}
0 commit comments