Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
227:d642169490f7 | 228:756b895e1dab |
---|---|
33 // First block: files included from the FIFE root src directory | 33 // First block: files included from the FIFE root src directory |
34 // Second block: files included from the same folder | 34 // Second block: files included from the same folder |
35 #include "util/base/exception.h" | 35 #include "util/base/exception.h" |
36 #include "util/log/logger.h" | 36 #include "util/log/logger.h" |
37 #include "util/structures/rect.h" | 37 #include "util/structures/rect.h" |
38 #include "util/utf8/utf8.h" | |
38 #include "video/image.h" | 39 #include "video/image.h" |
39 #include "video/renderbackend.h" | 40 #include "video/renderbackend.h" |
40 #include "video/imagepool.h" | 41 #include "video/imagepool.h" |
41 | 42 |
42 #include "subimagefont.h" | 43 #include "subimagefont.h" |
91 // Disable alpha blending, so that we use colorkeying | 92 // Disable alpha blending, so that we use colorkeying |
92 SDL_SetAlpha(surface,0,255); | 93 SDL_SetAlpha(surface,0,255); |
93 SDL_SetColorKey(surface,SDL_SRCCOLORKEY,colorkey); | 94 SDL_SetColorKey(surface,SDL_SRCCOLORKEY,colorkey); |
94 | 95 |
95 // Finally extract all glyphs | 96 // Finally extract all glyphs |
96 for(size_t i=0; i != glyphs.size(); ++i) { | 97 std::string::const_iterator text_it = glyphs.begin(); |
98 while(text_it != glyphs.end()) { | |
97 w=0; | 99 w=0; |
98 while(x < surface->w && pixels[x] == separator) | 100 while(x < surface->w && pixels[x] == separator) |
99 ++x; | 101 ++x; |
100 if( x == surface->w ) | 102 if( x == surface->w ) |
101 break; | 103 break; |
116 // Disable alpha blending, so that we use colorkeying | 118 // Disable alpha blending, so that we use colorkeying |
117 SDL_SetAlpha(tmp,0,255); | 119 SDL_SetAlpha(tmp,0,255); |
118 SDL_SetColorKey(tmp,SDL_SRCCOLORKEY,colorkey); | 120 SDL_SetColorKey(tmp,SDL_SRCCOLORKEY,colorkey); |
119 | 121 |
120 | 122 |
121 m_glyphs[ glyphs[i] ].surface = tmp; | 123 uint32_t codepoint = utf8::next(text_it, glyphs.end()); |
124 m_glyphs[ codepoint ].surface = tmp; | |
122 | 125 |
123 x += w; | 126 x += w; |
124 } | 127 } |
125 | 128 |
126 // Set placeholder glyph | 129 // Set placeholder glyph |
130 // This should actually work ith utf8. | |
127 if( m_glyphs.find('?') != m_glyphs.end() ) { | 131 if( m_glyphs.find('?') != m_glyphs.end() ) { |
128 m_placeholder = m_glyphs['?']; | 132 m_placeholder = m_glyphs['?']; |
129 } else { | 133 } else { |
130 m_placeholder.surface = 0; | 134 m_placeholder.surface = 0; |
131 } | 135 } |