summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2010-11-23 17:59:50 +0000
committerglx <glx@openttd.org>2010-11-23 17:59:50 +0000
commitd9173858a2740eee017ba2177c054e44d1842a3c (patch)
treeb093dc402aa6c335b44c4ffdc2c07e3dce02a456 /src/strings.cpp
parentc72fdad0bb0e4ae825cc61bdd2d72ac58e6213bb (diff)
downloadopenttd-d9173858a2740eee017ba2177c054e44d1842a3c.tar.xz
(svn r21298) -Fix [FS#4261]: fonts set in openttd.cfg were not properly checked for missing glyphs on language change
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 8b1fd6ade..1d5d63d69 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1568,16 +1568,19 @@ const char *GetCurrentLanguageIsoCode()
* Check whether there are glyphs missing in the current language.
* @param Pointer to an address for storing the text pointer.
* @return If glyphs are missing, return \c true, else return \false.
- * @pre *str must not be \c NULL.
- * @post If \c true is returned, *str points to a string that is found to contain at least one missing glyph.
+ * @post If \c true is returned and str is not NULL, *str points to a string that is found to contain at least one missing glyph.
*/
static bool FindMissingGlyphs(const char **str)
{
+#ifdef WITH_FREETYPE
+ UninitFreeType();
+ InitFreeType();
+#endif
const Sprite *question_mark = GetGlyph(FS_NORMAL, '?');
for (uint i = 0; i != 32; i++) {
for (uint j = 0; j < _langtab_num[i]; j++) {
const char *text = _langpack_offs[_langtab_start[i] + j];
- *str = text;
+ if (str != NULL) *str = text;
for (WChar c = Utf8Consume(&text); c != '\0'; c = Utf8Consume(&text)) {
if (c == SCC_SETX) {
/* SetX is, together with SetXY as special character that
@@ -1608,15 +1611,7 @@ static bool FindMissingGlyphs(const char **str)
*/
void CheckForMissingGlyphsInLoadedLanguagePack()
{
-#ifdef WITH_FREETYPE
- /* Reset to the original state; switching languages might cause us to
- * automatically choose another font. This resets that choice. */
- UninitFreeType();
- InitFreeType();
-#endif
-
- const char *str;
- bool bad_font = FindMissingGlyphs(&str);
+ bool bad_font = FindMissingGlyphs(NULL);
#ifdef WITH_FREETYPE
if (bad_font) {
/* We found an unprintable character... lets try whether we can find
@@ -1624,23 +1619,16 @@ void CheckForMissingGlyphsInLoadedLanguagePack()
FreeTypeSettings backup;
memcpy(&backup, &_freetype, sizeof(backup));
- bool success = SetFallbackFont(&_freetype, _langpack->isocode, _langpack->winlangid, str);
- if (success) {
- UninitFreeType();
- InitFreeType();
- }
+ bad_font = !SetFallbackFont(&_freetype, _langpack->isocode, _langpack->winlangid, &FindMissingGlyphs);
memcpy(&_freetype, &backup, sizeof(backup));
- if (success) {
- bad_font = FindMissingGlyphs(&str);
- if (bad_font) {
- /* Our fallback font does miss characters too, so keep the
- * user chosen font as that is more likely to be any good than
- * the wild guess we made */
- UninitFreeType();
- InitFreeType();
- }
+ if (bad_font) {
+ /* Our fallback font does miss characters too, so keep the
+ * user chosen font as that is more likely to be any good than
+ * the wild guess we made */
+ UninitFreeType();
+ InitFreeType();
}
}
#endif