diff engine/core/video/fonts/subimagefont.cpp @ 228:756b895e1dab

Merged unicode-support back into trunk. Now all GUI/visible strings should be unicode. Internal strings unchanged. Remember to use a font that actually has the desired codepoints. Current default unicode policiy is 'ignore'.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 21 Mar 2009 10:38:11 +0000
parents 90005975cdbb
children ad7969d9460b
line wrap: on
line diff
--- a/engine/core/video/fonts/subimagefont.cpp	Fri Mar 20 15:17:28 2009 +0000
+++ b/engine/core/video/fonts/subimagefont.cpp	Sat Mar 21 10:38:11 2009 +0000
@@ -35,6 +35,7 @@
 #include "util/base/exception.h"
 #include "util/log/logger.h"
 #include "util/structures/rect.h"
+#include "util/utf8/utf8.h"
 #include "video/image.h"
 #include "video/renderbackend.h"
 #include "video/imagepool.h"
@@ -93,7 +94,8 @@
 		SDL_SetColorKey(surface,SDL_SRCCOLORKEY,colorkey);
 
 		// Finally extract all glyphs
-		for(size_t i=0; i != glyphs.size(); ++i) {
+		std::string::const_iterator text_it = glyphs.begin();
+		while(text_it != glyphs.end()) {
 			w=0;
 			while(x < surface->w && pixels[x] == separator)
 				++x;
@@ -118,12 +120,14 @@
 			SDL_SetColorKey(tmp,SDL_SRCCOLORKEY,colorkey);
 
 
-			m_glyphs[ glyphs[i] ].surface = tmp;
+			uint32_t codepoint = utf8::next(text_it, glyphs.end());
+			m_glyphs[ codepoint ].surface = tmp;
 
 			x += w;
 		}
 
 		// Set placeholder glyph
+		// This should actually work ith utf8.
 		if( m_glyphs.find('?') != m_glyphs.end() ) {
 			m_placeholder = m_glyphs['?'];
 		} else {