src/fontcache.cpp
changeset 5609 dc6a58930ba4
parent 5587 167d9a91ef02
child 5638 ee1871005c80
equal deleted inserted replaced
5608:0b0aff054402 5609:dc6a58930ba4
    76 
    76 
    77 	/* For Unicode we need some conversion between widechar and
    77 	/* For Unicode we need some conversion between widechar and
    78 	 * normal char to match the data returned by RegEnumValue,
    78 	 * normal char to match the data returned by RegEnumValue,
    79 	 * otherwise just use parameter */
    79 	 * otherwise just use parameter */
    80 #if defined(UNICODE)
    80 #if defined(UNICODE)
    81 	MallocT(&font_namep, MAX_PATH);
    81 	font_namep = MallocT<char>(MAX_PATH);
    82 	MB_TO_WIDE_BUFFER(font_name, font_namep, MAX_PATH * sizeof(TCHAR));
    82 	MB_TO_WIDE_BUFFER(font_name, font_namep, MAX_PATH * sizeof(TCHAR));
    83 #else
    83 #else
    84 	font_namep = (char*)font_name; // only cast because in unicode pointer is not const
    84 	font_namep = (char*)font_name; // only cast because in unicode pointer is not const
    85 #endif
    85 #endif
    86 
    86 
   344 
   344 
   345 static void SetGlyphPtr(FontSize size, WChar key, const GlyphEntry *glyph)
   345 static void SetGlyphPtr(FontSize size, WChar key, const GlyphEntry *glyph)
   346 {
   346 {
   347 	if (_glyph_ptr[size] == NULL) {
   347 	if (_glyph_ptr[size] == NULL) {
   348 		DEBUG(freetype, 3, "Allocating root glyph cache for size %u", size);
   348 		DEBUG(freetype, 3, "Allocating root glyph cache for size %u", size);
   349 		CallocT(&_glyph_ptr[size], 256);
   349 		_glyph_ptr[size] = CallocT<GlyphEntry*>(256);
   350 	}
   350 	}
   351 
   351 
   352 	if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) {
   352 	if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) {
   353 		DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size);
   353 		DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size);
   354 		CallocT(&_glyph_ptr[size][GB(key, 8, 8)], 256);
   354 		_glyph_ptr[size][GB(key, 8, 8)] = CallocT<GlyphEntry>(256);
   355 	}
   355 	}
   356 
   356 
   357 	DEBUG(freetype, 4, "Set glyph for unicode character 0x%04X, size %u", key, size);
   357 	DEBUG(freetype, 4, "Set glyph for unicode character 0x%04X, size %u", key, size);
   358 	_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite;
   358 	_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite;
   359 	_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].width  = glyph->width;
   359 	_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].width  = glyph->width;
   482 }
   482 }
   483 
   483 
   484 
   484 
   485 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite)
   485 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite)
   486 {
   486 {
   487 	if (_unicode_glyph_map[size] == NULL) CallocT(&_unicode_glyph_map[size], 256);
   487 	if (_unicode_glyph_map[size] == NULL) _unicode_glyph_map[size] = CallocT<SpriteID*>(256);
   488 	if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) CallocT(&_unicode_glyph_map[size][GB(key, 8, 8)], 256);
   488 	if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) _unicode_glyph_map[size][GB(key, 8, 8)] = CallocT<SpriteID>(256);
   489 	_unicode_glyph_map[size][GB(key, 8, 8)][GB(key, 0, 8)] = sprite;
   489 	_unicode_glyph_map[size][GB(key, 8, 8)][GB(key, 0, 8)] = sprite;
   490 }
   490 }
   491 
   491 
   492 
   492 
   493 void InitializeUnicodeGlyphMap(void)
   493 void InitializeUnicodeGlyphMap(void)