diff options
author | peter1138 <peter1138@openttd.org> | 2006-05-09 13:23:04 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-05-09 13:23:04 +0000 |
commit | fd778ecafa01761e68cff310368dd035020f6b07 (patch) | |
tree | 8005097e607d7cdb0d7b03e2627fbc55efcfdd0d /gfx.h | |
parent | 52bab5e9bd30a5a8f20eba8a838748e3402fa87a (diff) | |
download | openttd-fd778ecafa01761e68cff310368dd035020f6b07.tar.xz |
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
Diffstat (limited to 'gfx.h')
-rw-r--r-- | gfx.h | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -36,6 +36,14 @@ typedef struct CursorVars { } CursorVars; +typedef enum FontSizes { + FS_NORMAL, + FS_SMALL, + FS_LARGE, + FS_END, +} FontSize; + + void RedrawScreenRect(int left, int top, int right, int bottom); void GfxScroll(int left, int top, int width, int height, int xo, int yo); @@ -94,12 +102,23 @@ void ToggleFullScreen(bool fs); /* gfx.c */ #define ASCII_LETTERSTART 32 -VARDEF int _stringwidth_base; -VARDEF byte _stringwidth_table[0x2A0]; -static inline byte GetCharacterWidth(uint key) +extern FontSize _cur_fontsize; +extern byte _stringwidth_table[FS_END][224]; + +static inline byte GetCharacterWidth(FontSize size, byte key) +{ + assert(key >= ASCII_LETTERSTART); + return _stringwidth_table[size][key - ASCII_LETTERSTART]; +} + +static inline byte GetCharacterHeight(FontSize size) { - assert(key >= ASCII_LETTERSTART && key - ASCII_LETTERSTART < lengthof(_stringwidth_table)); - return _stringwidth_table[key - ASCII_LETTERSTART]; + switch (size) { + default: NOT_REACHED(); + case FS_NORMAL: return 10; + case FS_SMALL: return 6; + case FS_LARGE: return 18; + } } VARDEF DrawPixelInfo _screen; |