|
1 /* $Id$ */ |
|
2 |
|
3 #ifndef FONTCACHE_H |
|
4 #define FONTCACHE_H |
|
5 |
|
6 /** Get the SpriteID mapped to the given font size and key */ |
|
7 SpriteID GetUnicodeGlyph(FontSize size, uint32 key); |
|
8 |
|
9 /** Map a SpriteID to the font size and key */ |
|
10 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite); |
|
11 |
|
12 /** Initialize the glyph map */ |
|
13 void InitializeUnicodeGlyphMap(void); |
|
14 |
|
15 #ifdef WITH_FREETYPE |
|
16 |
|
17 typedef struct FreeTypeSettings { |
|
18 char small_font[260]; |
|
19 char medium_font[260]; |
|
20 char large_font[260]; |
|
21 uint small_size; |
|
22 uint medium_size; |
|
23 uint large_size; |
|
24 } FreeTypeSettings; |
|
25 |
|
26 extern FreeTypeSettings _freetype; |
|
27 |
|
28 void InitFreeType(void); |
|
29 const struct Sprite *GetGlyph(FontSize size, uint32 key); |
|
30 uint GetGlyphWidth(FontSize size, uint32 key); |
|
31 |
|
32 #else |
|
33 |
|
34 /* Stub for initializiation */ |
|
35 static inline void InitFreeType(void) {} |
|
36 |
|
37 /** Get the Sprite for a glyph */ |
|
38 static inline const Sprite *GetGlyph(FontSize size, uint32 key) |
|
39 { |
|
40 SpriteID sprite = GetUnicodeGlyph(size, key); |
|
41 if (sprite == 0) sprite = GetUnicodeGlyph(size, '?'); |
|
42 return GetSprite(sprite); |
|
43 } |
|
44 |
|
45 |
|
46 /** Get the width of a glyph */ |
|
47 static inline uint GetGlyphWidth(FontSize size, uint32 key) |
|
48 { |
|
49 SpriteID sprite = GetUnicodeGlyph(size, key); |
|
50 if (sprite == 0) sprite = GetUnicodeGlyph(size, '?'); |
|
51 return SpriteExists(sprite) ? GetSprite(sprite)->width + (size != FS_NORMAL) : 0; |
|
52 } |
|
53 |
|
54 #endif /* WITH_FREETYPE */ |
|
55 |
|
56 #endif /* FONTCACHE_H */ |