aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Crozat2010-08-20 21:50:58 +0000
committerThierry Crozat2010-08-20 21:50:58 +0000
commit769ad3109dfd54a61ffc9ebc02333986d9a3d8a4 (patch)
tree5240b7a546e93e0400fd8cbaa9dd74946a9d5c23
parentf8957603e624ed98a712b61634c80428eaad9e3a (diff)
downloadscummvm-rg350-769ad3109dfd54a61ffc9ebc02333986d9a3d8a4.tar.gz
scummvm-rg350-769ad3109dfd54a61ffc9ebc02333986d9a3d8a4.tar.bz2
scummvm-rg350-769ad3109dfd54a61ffc9ebc02333986d9a3d8a4.zip
GUI: fix crash when localized font could not be found
The ThemeEngine had a fallback implemented to use the non-localized font if the localized one (e.g. for Hungarian) could not be found. However the fallback was not working. Now it is working. svn-id: r52243
-rw-r--r--gui/ThemeEngine.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 3a50b2c69c..aa8ed4293e 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -575,15 +575,26 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) {
if (!_texts[textId]->_fontPtr) {
// First try to load localized font
_texts[textId]->_fontPtr = loadFont(localized);
+
+ if (_texts[textId]->_fontPtr)
+ FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
// Fallback to non-localized font
- if (!_texts[textId]->_fontPtr)
- _texts[textId]->_fontPtr = loadFont(file);
-
- if (!_texts[textId]->_fontPtr)
- error("Couldn't load font '%s'", file.c_str());
-
- FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
+ else {
+ // Try built-in fonts
+ _texts[textId]->_fontPtr = FontMan.getFontByName(file);
+
+ // Try to load it
+ if (!_texts[textId]->_fontPtr) {
+ _texts[textId]->_fontPtr = loadFont(file);
+
+ if (!_texts[textId]->_fontPtr)
+ error("Couldn't load font '%s'", file.c_str());
+
+ FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
+ }
+ warning("Failed to load localized font '%s'. Using non-localized font instead", file.c_str());
+ }
}
}