# fontcache.h

Go to the documentation of this file.

    00001 /* $Id: fontcache.h 14618 2008-11-24 18:53:17Z rubidium $ */
    00002
    00005 #ifndef FONTCACHE_H
    00006 #define FONTCACHE_H
    00007
    00008 #include "gfx_type.h"
    00009
    00011 SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
    00012
    00014 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite);
    00015
    00017 void InitializeUnicodeGlyphMap();
    00018
    00019 #ifdef WITH_FREETYPE
    00020
    00021 struct FreeTypeSettings {
    00022   char small_font[MAX_PATH];
    00023   char medium_font[MAX_PATH];
    00024   char large_font[MAX_PATH];
    00025   uint small_size;
    00026   uint medium_size;
    00027   uint large_size;
    00028   bool small_aa;
    00029   bool medium_aa;
    00030   bool large_aa;
    00031 };
    00032
    00033 extern FreeTypeSettings _freetype;
    00034
    00035 void InitFreeType();
    00036 void UninitFreeType();
    00037 const struct Sprite *GetGlyph(FontSize size, uint32 key);
    00038 uint GetGlyphWidth(FontSize size, uint32 key);
    00039
    00049 bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid);
    00050
    00051 #else
    00052
    00053 /* Stub for initializiation */
    00054 static inline void InitFreeType() {}
    00055 static inline void UninitFreeType() {}
    00056
    00058 static inline const Sprite *GetGlyph(FontSize size, uint32 key)
    00059 {
    00060   SpriteID sprite = GetUnicodeGlyph(size, key);
    00061   if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
    00062   return GetSprite(sprite, ST_FONT);
    00063 }
    00064
    00065
    00067 static inline uint GetGlyphWidth(FontSize size, uint32 key)
    00068 {
    00069   SpriteID sprite = GetUnicodeGlyph(size, key);
    00070   if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
    00071   return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + (size != FS_NORMAL) : 0;
    00072 }
    00073
    00074 #endif /* WITH_FREETYPE */
    00075
    00076 #endif /* FONTCACHE_H */