Mercurial > fife-parpg
comparison engine/core/video/fonts/fontbase.cpp @ 419:6dace911ac2d
Fixes a freeze when setting text in a label with word_wrap enabled. [t:408]
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 06 Feb 2010 20:38:37 +0000 |
parents | 7887f3854862 |
children | 5d6b1820b953 |
comparison
equal
deleted
inserted
replaced
418:70ba57cd9d18 | 419:6dace911ac2d |
---|---|
180 std::string line; | 180 std::string line; |
181 std::string::const_iterator pos = text.begin(); | 181 std::string::const_iterator pos = text.begin(); |
182 std::list<std::pair<size_t,std::string::const_iterator> > break_pos; | 182 std::list<std::pair<size_t,std::string::const_iterator> > break_pos; |
183 bool firstLine = true; | 183 bool firstLine = true; |
184 | 184 |
185 while( pos != text.end() ) | 185 while( pos != text.end()) |
186 { | 186 { |
187 break_pos.clear(); | 187 break_pos.clear(); |
188 if( !firstLine ) { | 188 if( !firstLine ) { |
189 line = "\n"; | 189 line = "\n"; |
190 } else { | 190 } else { |
191 firstLine = false; | 191 firstLine = false; |
192 } | 192 } |
193 | 193 |
194 bool haveNewLine = false; | 194 bool haveNewLine = false; |
195 while( getWidth(line) < render_width && pos != text.end() ) | 195 while( getWidth(line) < render_width && pos != text.end() ) |
196 { | 196 { |
197 uint32_t codepoint = utf8::next(pos, text.end()); | 197 uint32_t codepoint = utf8::next(pos, text.end()); |
198 if (codepoint == whitespace && !line.empty()) | 198 if (codepoint == whitespace && !line.empty()) |
217 | 217 |
218 if( break_pos.empty() ) { | 218 if( break_pos.empty() ) { |
219 // No break position and line length smaller than 2 | 219 // No break position and line length smaller than 2 |
220 // means the renderwidth is really screwed. Just continue | 220 // means the renderwidth is really screwed. Just continue |
221 // appending single character lines. | 221 // appending single character lines. |
222 if( utf8::distance(line.begin(),line.end()) <= 1 ) { | 222 if( utf8::distance(line.begin(),line.end()) <= 1 && line != "\n") { |
223 output.append(line); | 223 output.append(line); |
224 continue; | 224 continue; |
225 } | |
226 | |
227 if (line == "\n") { | |
228 ++pos; | |
225 } | 229 } |
226 | 230 |
227 // We can't do hyphenation here, | 231 // We can't do hyphenation here, |
228 // so we just retreat one character :-( | 232 // so we just retreat one character :-( |
229 // FIXME | 233 // FIXME |