# fontcache.h

Go to the documentation of this file.

    00001 /* $Id: fontcache.h 18809 2010-01-15 16:41:15Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef FONTCACHE_H
    00013 #define FONTCACHE_H
    00014
    00015 #include "spritecache.h"
    00016
    00018 SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
    00019
    00021 void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite);
    00022
    00024 void InitializeUnicodeGlyphMap();
    00025
    00026 void ResetFontSizes();
    00027
    00028 #ifdef WITH_FREETYPE
    00029
    00030 struct FreeTypeSettings {
    00031   char small_font[MAX_PATH];
    00032   char medium_font[MAX_PATH];
    00033   char large_font[MAX_PATH];
    00034   uint small_size;
    00035   uint medium_size;
    00036   uint large_size;
    00037   bool small_aa;
    00038   bool medium_aa;
    00039   bool large_aa;
    00040 };
    00041
    00042 extern FreeTypeSettings _freetype;
    00043
    00044 void InitFreeType();
    00045 void UninitFreeType();
    00046 const Sprite *GetGlyph(FontSize size, uint32 key);
    00047 uint GetGlyphWidth(FontSize size, uint32 key);
    00048
    00058 bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, const char *str);
    00059
    00060 #else
    00061
    00062 /* Stub for initializiation */
    00063 static inline void InitFreeType() { ResetFontSizes(); }
    00064 static inline void UninitFreeType() { ResetFontSizes(); }
    00065
    00067 static inline const Sprite *GetGlyph(FontSize size, uint32 key)
    00068 {
    00069   SpriteID sprite = GetUnicodeGlyph(size, key);
    00070   if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
    00071   return GetSprite(sprite, ST_FONT);
    00072 }
    00073
    00074
    00076 static inline uint GetGlyphWidth(FontSize size, uint32 key)
    00077 {
    00078   SpriteID sprite = GetUnicodeGlyph(size, key);
    00079   if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
    00080   return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + (size != FS_NORMAL) : 0;
    00081 }
    00082
    00083 #endif /* WITH_FREETYPE */
    00084
    00085 #endif /* FONTCACHE_H */