summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2009-03-18 00:51:44 +0000
committerglx <glx@openttd.org>2009-03-18 00:51:44 +0000
commit5654966e7530100692e5350aae8599fdd43fbc59 (patch)
treea2725ad323d0c3537e87129f3422231758f61b36
parent022a929e2dd7e697d0f9039f0ac3079cd79b8a71 (diff)
downloadopenttd-5654966e7530100692e5350aae8599fdd43fbc59.tar.xz
(svn r15757) -Fix/hackaround (r15314): of course on some system searching a font using its english name fails. So now we search the font using the localised name and use the english name for the final 'validation' only.
-rw-r--r--src/fontcache.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index a3f45ec07..8a3f684f6 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -172,6 +172,8 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
if (err != FT_Err_Ok) break;
if (strncasecmp(font_name, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
+ /* Try english name if font name failed */
+ if (strncasecmp(font_name + strlen(font_name) + 1, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
err = FT_Err_Cannot_Open_Resource;
} while ((FT_Long)++index != (*face)->num_faces);
@@ -296,12 +298,18 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
if ((fs.fsCsb[0] & info->locale.lsCsbSupported[0]) == 0 && (fs.fsCsb[1] & info->locale.lsCsbSupported[1]) == 0) return 1;
}
- const char *font_name = GetEnglishFontName(logfont);
- DEBUG(freetype, 1, "Fallback font: %s", font_name);
+ const char *english_name = GetEnglishFontName(logfont);
+ const char *font_name = WIDE_TO_MB(logfont->elfFullName);
+ DEBUG(freetype, 1, "Fallback font: %s (%s)", font_name, english_name);
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));
+
+ /* Add english name after font name */
+ strecpy(info->settings->small_font + strlen(info->settings->small_font) + 1, english_name, lastof(info->settings->small_font));
+ strecpy(info->settings->medium_font + strlen(info->settings->medium_font) + 1, english_name, lastof(info->settings->medium_font));
+ strecpy(info->settings->large_font + strlen(info->settings->large_font) + 1, english_name, lastof(info->settings->large_font));
return 0; // stop enumerating
}