fontcache.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef FONTCACHE_H
00013 #define FONTCACHE_H
00014
00015 #include "gfx_type.h"
00016 #include "spritecache.h"
00017
00019 SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
00020
00022 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite);
00023
00025 void InitializeUnicodeGlyphMap();
00026
00027 void ResetFontSizes();
00028
00029 #ifdef WITH_FREETYPE
00030
00031 struct FreeTypeSettings {
00032 char small_font[MAX_PATH];
00033 char medium_font[MAX_PATH];
00034 char large_font[MAX_PATH];
00035 uint small_size;
00036 uint medium_size;
00037 uint large_size;
00038 bool small_aa;
00039 bool medium_aa;
00040 bool large_aa;
00041 };
00042
00043 extern FreeTypeSettings _freetype;
00044
00045 void InitFreeType();
00046 void UninitFreeType();
00047 const Sprite *GetGlyph(FontSize size, uint32 key);
00048 uint GetGlyphWidth(FontSize size, uint32 key);
00049
00059 bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, const char *str);
00060
00061 #else
00062
00063
00064 static inline void InitFreeType() { ResetFontSizes(); }
00065 static inline void UninitFreeType() { ResetFontSizes(); }
00066
00068 static inline const Sprite *GetGlyph(FontSize size, uint32 key)
00069 {
00070 SpriteID sprite = GetUnicodeGlyph(size, key);
00071 if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
00072 return GetSprite(sprite, ST_FONT);
00073 }
00074
00075
00077 static inline uint GetGlyphWidth(FontSize size, uint32 key)
00078 {
00079 SpriteID sprite = GetUnicodeGlyph(size, key);
00080 if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
00081 return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + (size != FS_NORMAL) : 0;
00082 }
00083
00084 #endif
00085
00086 #endif