[Scummvm-cvs-logs] SF.net SVN: scummvm:[52243] scummvm/trunk/gui/ThemeEngine.cpp

criezy at users.sourceforge.net criezy at users.sourceforge.net
Fri Aug 20 23:50:58 CEST 2010


Revision: 52243
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52243&view=rev
Author:   criezy
Date:     2010-08-20 21:50:58 +0000 (Fri, 20 Aug 2010)

Log Message:
-----------
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. 

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeEngine.cpp

Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp	2010-08-20 21:05:56 UTC (rev 52242)
+++ scummvm/trunk/gui/ThemeEngine.cpp	2010-08-20 21:50:58 UTC (rev 52243)
@@ -575,15 +575,26 @@
 		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);
+			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);
+					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());
+			}
 		}
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list