diff options
author | frosch <frosch@openttd.org> | 2013-07-06 18:56:23 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-07-06 18:56:23 +0000 |
commit | 4824cb78863ff8b5ff631631a1fd8b5c8dfba500 (patch) | |
tree | dfaeb357932ce8177d66ea3544ce42f8d500cf5f /src/gfx_layout.h | |
parent | 72a531bc82d5458d8f3483ffa88332b673a819d4 (diff) | |
download | openttd-4824cb78863ff8b5ff631631a1fd8b5c8dfba500.tar.xz |
(svn r25569) -Codechange: Cache all Font instances in a static container.
Diffstat (limited to 'src/gfx_layout.h')
-rw-r--r-- | src/gfx_layout.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gfx_layout.h b/src/gfx_layout.h index 6dbf3f872..ea9c34aae 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -167,12 +167,16 @@ class Layouter : public AutoDeleteSmallVector<ParagraphLayout::Line *, 4> { ParagraphLayout *GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping); CharType buffer[DRAW_STRING_BUFFER]; ///< Buffer for the text that is going to be drawn. - SmallVector<Font *, 4> fonts; ///< The fonts needed for drawing. + + typedef SmallMap<TextColour, Font *> FontColourMap; + static FontColourMap fonts[FS_END]; + static Font *GetFont(FontSize size, TextColour colour); public: Layouter(const char *str, int maxw = INT32_MAX, TextColour colour = TC_FROMSTRING, FontSize fontsize = FS_NORMAL); - ~Layouter(); Dimension GetBounds(); + + static void ResetFontCache(FontSize size); }; #endif /* GFX_LAYOUT_H */ |