diff options
author | rubidium <rubidium@openttd.org> | 2011-11-19 18:43:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-11-19 18:43:00 +0000 |
commit | 447884fddbfbec520a927cfdaa1aaad5127cca9d (patch) | |
tree | 51727955c2bad4111b0ed6555c43e73a7b528e35 /src/fontcache.cpp | |
parent | 32b28bb86819411c427c694ec26616d0bc45fdb3 (diff) | |
download | openttd-447884fddbfbec520a927cfdaa1aaad5127cca9d.tar.xz |
(svn r23265) -Codechange: replace the setfallbackfont callback function with a class to call back
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r-- | src/fontcache.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp index fdc662659..255589943 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -13,6 +13,7 @@ #include "fontcache.h" #include "blitter/factory.hpp" #include "core/math_func.hpp" +#include "strings_func.h" #include "table/sprites.h" #include "table/control_codes.h" @@ -289,7 +290,7 @@ err1: struct EFCParam { FreeTypeSettings *settings; LOCALESIGNATURE locale; - SetFallbackFontCallback *callback; + MissingGlyphSearcher *callback; }; static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXTMETRICEX *metric, DWORD type, LPARAM lParam) @@ -349,12 +350,12 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT strecpy(info->settings->small_font, font_name, lastof(info->settings->small_font)); strecpy(info->settings->medium_font, font_name, lastof(info->settings->medium_font)); strecpy(info->settings->large_font, font_name, lastof(info->settings->large_font)); - if (info->callback(NULL)) return 1; + if (info->callback->FindMissingGlyphs(NULL)) return 1; DEBUG(freetype, 1, "Fallback font: %s (%s)", font_name, english_name); return 0; // stop enumerating } -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, SetFallbackFontCallback *callback) +bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { DEBUG(freetype, 1, "Trying fallback fonts"); EFCParam langInfo; @@ -428,12 +429,12 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) return err; } -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, SetFallbackFontCallback *callback) +bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { const char *str; bool result = false; - callback(&str); + callback->FindMissingGlyphs(&str); #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (MacOSVersionIsAtLeast(10, 5, 0)) { @@ -609,7 +610,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i } } - callback(NULL); + callback->FindMissingGlyphs(NULL); return result; } @@ -683,7 +684,7 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) return err; } -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, SetFallbackFontCallback *callback) +bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { if (!FcInit()) return false; @@ -722,7 +723,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i strecpy(settings->medium_font, (const char*)file, lastof(settings->medium_font)); strecpy(settings->large_font, (const char*)file, lastof(settings->large_font)); - bool missing = callback(NULL); + bool missing = callback->FindMissingGlyphs(NULL); DEBUG(freetype, 1, "Font \"%s\" misses%s glyphs", file, missing ? "" : " no"); if (!missing) { @@ -741,7 +742,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i #else /* without WITH_FONTCONFIG */ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) {return FT_Err_Cannot_Open_Resource;} -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, SetFallbackFontCallback *callback) { return false; } +bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { return false; } #endif /* WITH_FONTCONFIG */ static void SetFontGeometry(FT_Face face, FontSize size, int pixels) |