Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType
Commits:
-
0db69970
by Alexei Podtelezhnikov at 2023-03-30T09:06:35-04:00
1 changed file:
Changes:
... | ... | @@ -164,7 +164,7 @@ |
164 | 164 | FT_Error error;
|
165 | 165 | |
166 | 166 | FT_Int num_glyphs;
|
167 | - FT_UShort num_names;
|
|
167 | + FT_UShort num_names = 0;
|
|
168 | 168 | |
169 | 169 | FT_UShort* glyph_indices = NULL;
|
170 | 170 | FT_Byte** name_strings = NULL;
|
... | ... | @@ -186,9 +186,10 @@ |
186 | 186 | goto Exit;
|
187 | 187 | }
|
188 | 188 | |
189 | - /* load the indices */
|
|
189 | + /* load the indices and note their maximum */
|
|
190 | 190 | {
|
191 | - FT_Int n;
|
|
191 | + FT_Int n;
|
|
192 | + FT_UShort idx;
|
|
192 | 193 | |
193 | 194 | |
194 | 195 | if ( FT_QNEW_ARRAY( glyph_indices, num_glyphs ) ||
|
... | ... | @@ -196,32 +197,18 @@ |
196 | 197 | goto Fail;
|
197 | 198 | |
198 | 199 | for ( n = 0; n < num_glyphs; n++ )
|
199 | - glyph_indices[n] = FT_GET_USHORT();
|
|
200 | + {
|
|
201 | + glyph_indices[n] = idx = FT_GET_USHORT();
|
|
202 | + |
|
203 | + if ( idx > num_names )
|
|
204 | + num_names = idx;
|
|
205 | + }
|
|
200 | 206 | |
201 | 207 | FT_FRAME_EXIT();
|
202 | 208 | }
|
203 | 209 | |
204 | 210 | /* compute number of names stored in table */
|
205 | - {
|
|
206 | - FT_Int n;
|
|
207 | - |
|
208 | - |
|
209 | - num_names = 0;
|
|
210 | - |
|
211 | - for ( n = 0; n < num_glyphs; n++ )
|
|
212 | - {
|
|
213 | - FT_Int idx;
|
|
214 | - |
|
215 | - |
|
216 | - idx = glyph_indices[n];
|
|
217 | - if ( idx >= 258 )
|
|
218 | - {
|
|
219 | - idx -= 257;
|
|
220 | - if ( idx > num_names )
|
|
221 | - num_names = (FT_UShort)idx;
|
|
222 | - }
|
|
223 | - }
|
|
224 | - }
|
|
211 | + num_names = num_names > 257 ? num_names - 257 : 0;
|
|
225 | 212 | |
226 | 213 | /* now load the name strings */
|
227 | 214 | if ( num_names )
|