[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src font.cpp
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src font.cpp |
Date: |
Sun, 03 Apr 2005 13:41:25 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/04/03 17:41:25
Modified files:
src : font.cpp
Log message:
Fixed the help crashing the game in font::word_wrap_text
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.129&tr2=1.130&r1=text&r2=text
Patches:
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.129 wesnoth/src/font.cpp:1.130
--- wesnoth/src/font.cpp:1.129 Sat Apr 2 14:06:35 2005
+++ wesnoth/src/font.cpp Sun Apr 3 17:41:25 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.129 2005/04/02 14:06:35 gruikya Exp $ */
+/* $Id: font.cpp,v 1.130 2005/04/03 17:41:25 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -859,16 +859,23 @@
{
std::string tmp = line;
utils::utf8_iterator tc(word);
+ bool first = true;
for(;tc != utils::utf8_iterator::end(word); ++tc) {
tmp.append(tc.substr().first, tc.substr().second);
SDL_Rect tsize = line_size(tmp, size);
if(tsize.w > max_width) {
const std::string& w = word;
- line += std::string(w.begin(), tc.substr().first);
- word = std::string(tc.substr().first, w.end());
+ if(line.empty() && first) {
+ line += std::string(w.begin(),
tc.substr().second);
+ word = std::string(tc.substr().second, w.end());
+ } else {
+ line += std::string(w.begin(),
tc.substr().first);
+ word = std::string(tc.substr().first, w.end());
+ }
break;
}
+ first = false;
}
}
@@ -881,6 +888,7 @@
std::string current_line;
size_t current_height = 0;
bool line_break = false;
+ bool first = true;
std::string wrapped_text;
while(1) {
@@ -906,9 +914,9 @@
} else {
SDL_Rect size = line_size(current_line + current_word,
font_size);
- if(size.w >= max_width) {
+ if(size.w > max_width) {
SDL_Rect wsize = line_size(current_word,
font_size);
- if(wsize.w >= max_width) {
+ if(wsize.w > max_width) {
cut_word(current_line, current_word,
font_size, max_width);
}
if(current_word == " ")
@@ -925,10 +933,13 @@
if(max_height > 0 && current_height + size.h >=
size_t(max_height))
return wrapped_text;
- wrapped_text += "\n" + current_line;
+ if(!first)
+ wrapped_text += '\n';
+ wrapped_text += current_line;
current_line = "";
current_height += size.h;
line_break = false;
+ first = false;
}
}
return wrapped_text;
- [Wesnoth-cvs-commits] wesnoth/src font.cpp,
Philippe Plantier <=