Mercurial > fife-parpg
comparison engine/core/video/fonts/imagefontbase.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 | 47b49b9b0c0a |
comparison
equal
deleted
inserted
replaced
227:d642169490f7 | 228:756b895e1dab |
---|---|
32 // These includes are split up in two parts, separated by one empty line | 32 // These includes are split up in two parts, separated by one empty line |
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/structures/rect.h" | 36 #include "util/structures/rect.h" |
37 #include "util/utf8/utf8.h" | |
37 #include "video/image.h" | 38 #include "video/image.h" |
38 #include "video/renderbackend.h" | 39 #include "video/renderbackend.h" |
39 | 40 |
40 #include "imagefontbase.h" | 41 #include "imagefontbase.h" |
41 | 42 |
52 | 53 |
53 } | 54 } |
54 | 55 |
55 int ImageFontBase::getWidth(const std::string& text) const { | 56 int ImageFontBase::getWidth(const std::string& text) const { |
56 int w = 0; | 57 int w = 0; |
57 | 58 std::string::const_iterator text_it = text.begin(); |
58 for(size_t i=0; i!= text.size(); ++i) { | 59 while(text_it != text.end()) { |
59 type_glyphs::const_iterator it = m_glyphs.find( text[i] ); | 60 uint32_t codepoint = utf8::next(text_it,text.end()); |
61 type_glyphs::const_iterator it = m_glyphs.find( codepoint ); | |
60 | 62 |
61 if( it != m_glyphs.end() ) { | 63 if( it != m_glyphs.end() ) { |
62 w += it->second.surface->w + getGlyphSpacing(); | 64 w += it->second.surface->w + getGlyphSpacing(); |
63 continue; | 65 continue; |
64 } | 66 } |
83 | 85 |
84 SDL_Rect dst; | 86 SDL_Rect dst; |
85 dst.x = dst.y = 0; | 87 dst.x = dst.y = 0; |
86 s_glyph *glyph = 0; | 88 s_glyph *glyph = 0; |
87 | 89 |
88 for(size_t i=0; i!= text.size(); ++i) { | 90 std::string::const_iterator text_it = text.begin(); |
89 type_glyphs::iterator it = m_glyphs.find( text[i] ); | 91 while(text_it != text.end()) { |
92 uint32_t codepoint = utf8::next(text_it,text.end()); | |
93 type_glyphs::iterator it = m_glyphs.find( codepoint ); | |
90 | 94 |
91 if( it == m_glyphs.end() ) { | 95 if( it == m_glyphs.end() ) { |
92 if( !m_placeholder.surface ) { | 96 if( !m_placeholder.surface ) { |
93 continue; | 97 continue; |
94 } | 98 } |