166 static FT_Error
167 sfnt_get_glyph_name( FT_Face face,
168 FT_UInt glyph_index,
169 FT_Pointer buffer,
170 FT_UInt buffer_max )
171 {
172 FT_String* gname;
173 FT_Error error;
174
175
176 error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname );
177 if ( !error )
178 FT_STRCPYN( buffer, gname, buffer_max );
179
180 return error;
181 }
182
183
184 static FT_UInt
185 sfnt_get_name_index( FT_Face face,
186 FT_String* glyph_name )
187 {
188 TT_Face ttface = (TT_Face)face;
189
190 FT_UInt i, max_gid = FT_UINT_MAX;
191
192
193 if ( face->num_glyphs < 0 )
194 return 0;
195 else if ( (FT_ULong)face->num_glyphs < FT_UINT_MAX )
196 max_gid = (FT_UInt)face->num_glyphs;
197 else
198 FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n",
199 FT_UINT_MAX, face->num_glyphs ));
200
201 for ( i = 0; i < max_gid; i++ )
202 {
203 FT_String* gname;
204 FT_Error error = tt_face_get_ps_name( ttface, i, &gname );
205
206
358 h4 ^= k4;
359
360 h4 = ROTL32( h4, 13 );
361 h4 += h1;
362 h4 = h4 * 5 + 0x32ac3b17;
363 }
364
365 {
366 const FT_Byte* tail = (const FT_Byte*)( data + nblocks * 16 );
367
368 FT_UInt32 k1 = 0;
369 FT_UInt32 k2 = 0;
370 FT_UInt32 k3 = 0;
371 FT_UInt32 k4 = 0;
372
373
374 switch ( len & 15 )
375 {
376 case 15:
377 k4 ^= (FT_UInt32)tail[14] << 16;
378 case 14:
379 k4 ^= (FT_UInt32)tail[13] << 8;
380 case 13:
381 k4 ^= (FT_UInt32)tail[12];
382 k4 *= c4;
383 k4 = ROTL32( k4, 18 );
384 k4 *= c1;
385 h4 ^= k4;
386
387 case 12:
388 k3 ^= (FT_UInt32)tail[11] << 24;
389 case 11:
390 k3 ^= (FT_UInt32)tail[10] << 16;
391 case 10:
392 k3 ^= (FT_UInt32)tail[9] << 8;
393 case 9:
394 k3 ^= (FT_UInt32)tail[8];
395 k3 *= c3;
396 k3 = ROTL32( k3, 17 );
397 k3 *= c4;
398 h3 ^= k3;
399
400 case 8:
401 k2 ^= (FT_UInt32)tail[7] << 24;
402 case 7:
403 k2 ^= (FT_UInt32)tail[6] << 16;
404 case 6:
405 k2 ^= (FT_UInt32)tail[5] << 8;
406 case 5:
407 k2 ^= (FT_UInt32)tail[4];
408 k2 *= c2;
409 k2 = ROTL32( k2, 16 );
410 k2 *= c3;
411 h2 ^= k2;
412
413 case 4:
414 k1 ^= (FT_UInt32)tail[3] << 24;
415 case 3:
416 k1 ^= (FT_UInt32)tail[2] << 16;
417 case 2:
418 k1 ^= (FT_UInt32)tail[1] << 8;
419 case 1:
420 k1 ^= (FT_UInt32)tail[0];
421 k1 *= c1;
422 k1 = ROTL32( k1, 15 );
423 k1 *= c2;
424 h1 ^= k1;
425 }
426 }
427
428 h1 ^= len;
429 h2 ^= len;
430 h3 ^= len;
431 h4 ^= len;
432
433 h1 += h2;
434 h1 += h3;
435 h1 += h4;
436
437 h2 += h1;
438 h3 += h1;
|
166 static FT_Error
167 sfnt_get_glyph_name( FT_Face face,
168 FT_UInt glyph_index,
169 FT_Pointer buffer,
170 FT_UInt buffer_max )
171 {
172 FT_String* gname;
173 FT_Error error;
174
175
176 error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname );
177 if ( !error )
178 FT_STRCPYN( buffer, gname, buffer_max );
179
180 return error;
181 }
182
183
184 static FT_UInt
185 sfnt_get_name_index( FT_Face face,
186 const FT_String* glyph_name )
187 {
188 TT_Face ttface = (TT_Face)face;
189
190 FT_UInt i, max_gid = FT_UINT_MAX;
191
192
193 if ( face->num_glyphs < 0 )
194 return 0;
195 else if ( (FT_ULong)face->num_glyphs < FT_UINT_MAX )
196 max_gid = (FT_UInt)face->num_glyphs;
197 else
198 FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n",
199 FT_UINT_MAX, face->num_glyphs ));
200
201 for ( i = 0; i < max_gid; i++ )
202 {
203 FT_String* gname;
204 FT_Error error = tt_face_get_ps_name( ttface, i, &gname );
205
206
358 h4 ^= k4;
359
360 h4 = ROTL32( h4, 13 );
361 h4 += h1;
362 h4 = h4 * 5 + 0x32ac3b17;
363 }
364
365 {
366 const FT_Byte* tail = (const FT_Byte*)( data + nblocks * 16 );
367
368 FT_UInt32 k1 = 0;
369 FT_UInt32 k2 = 0;
370 FT_UInt32 k3 = 0;
371 FT_UInt32 k4 = 0;
372
373
374 switch ( len & 15 )
375 {
376 case 15:
377 k4 ^= (FT_UInt32)tail[14] << 16;
378 /* fall through */
379 case 14:
380 k4 ^= (FT_UInt32)tail[13] << 8;
381 /* fall through */
382 case 13:
383 k4 ^= (FT_UInt32)tail[12];
384 k4 *= c4;
385 k4 = ROTL32( k4, 18 );
386 k4 *= c1;
387 h4 ^= k4;
388 /* fall through */
389
390 case 12:
391 k3 ^= (FT_UInt32)tail[11] << 24;
392 /* fall through */
393 case 11:
394 k3 ^= (FT_UInt32)tail[10] << 16;
395 /* fall through */
396 case 10:
397 k3 ^= (FT_UInt32)tail[9] << 8;
398 /* fall through */
399 case 9:
400 k3 ^= (FT_UInt32)tail[8];
401 k3 *= c3;
402 k3 = ROTL32( k3, 17 );
403 k3 *= c4;
404 h3 ^= k3;
405 /* fall through */
406
407 case 8:
408 k2 ^= (FT_UInt32)tail[7] << 24;
409 /* fall through */
410 case 7:
411 k2 ^= (FT_UInt32)tail[6] << 16;
412 /* fall through */
413 case 6:
414 k2 ^= (FT_UInt32)tail[5] << 8;
415 /* fall through */
416 case 5:
417 k2 ^= (FT_UInt32)tail[4];
418 k2 *= c2;
419 k2 = ROTL32( k2, 16 );
420 k2 *= c3;
421 h2 ^= k2;
422 /* fall through */
423
424 case 4:
425 k1 ^= (FT_UInt32)tail[3] << 24;
426 /* fall through */
427 case 3:
428 k1 ^= (FT_UInt32)tail[2] << 16;
429 /* fall through */
430 case 2:
431 k1 ^= (FT_UInt32)tail[1] << 8;
432 /* fall through */
433 case 1:
434 k1 ^= (FT_UInt32)tail[0];
435 k1 *= c1;
436 k1 = ROTL32( k1, 15 );
437 k1 *= c2;
438 h1 ^= k1;
439 }
440 }
441
442 h1 ^= len;
443 h2 ^= len;
444 h3 ^= len;
445 h4 ^= len;
446
447 h1 += h2;
448 h1 += h3;
449 h1 += h4;
450
451 h2 += h1;
452 h3 += h1;
|