wesnoth-cvs-commits
[Top][All Lists]
Advanced

[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, 17 Apr 2005 17:29:41 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/04/17 21:29:41

Modified files:
        src            : font.cpp 

Log message:
        Fixed the bug described in 
http://www.wesnoth.org/forum/viewtopic.php?t=5538 :
        made word_wrap_text retain start-of-line format characters.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.133&tr2=1.134&r1=text&r2=text

Patches:
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.133 wesnoth/src/font.cpp:1.134
--- wesnoth/src/font.cpp:1.133  Sat Apr  9 20:52:22 2005
+++ wesnoth/src/font.cpp        Sun Apr 17 21:29:41 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.133 2005/04/09 20:52:22 gruikya Exp $ */
+/* $Id: font.cpp,v 1.134 2005/04/17 21:29:41 gruikya Exp $ */
 /* vim:set encoding=utf-8: */
 /*
    Copyright (C) 2003 by David White <address@hidden>
@@ -947,11 +947,25 @@
        size_t current_height = 0;
        bool line_break = false;
        bool first = true;
+       bool start_of_line = true;
        std::string wrapped_text;
-       
+       std::string format_string;
+       utils::utf8_iterator end = utils::utf8_iterator::end(unwrapped_text);
+
        while(1) {
+               if(start_of_line) {
+                       format_string = "";
+                       while(ch != end && *ch < 0x100 && is_format_char(*ch)) {
+                               format_string.append(ch.substr().first, 
ch.substr().second);
+                               ++ch;
+                       }
+                       current_line = format_string;
+                       std::cerr << "Format string is " << format_string << 
"\n";
+                       start_of_line = false;
+               }
+
                // If there is no current word, get one
-               if(current_word.empty() && ch == 
utils::utf8_iterator::end(unwrapped_text)) {
+               if(current_word.empty() && ch == end) {
                        break;
                } else if(current_word.empty()) {
                        if(*ch == ' ' || *ch == '\n') {
@@ -982,6 +996,7 @@
                if(current_word == "\n") {
                        line_break = true;
                        current_word = "";
+                       start_of_line = true;
                } else {
                        SDL_Rect size = line_size(current_line + current_word, 
font_size);
 
@@ -999,7 +1014,7 @@
                        }
                }
 
-               if(line_break || current_word.empty() && ch == 
utils::utf8_iterator::end(unwrapped_text)) {
+               if(line_break || current_word.empty() && ch == end) {
                        SDL_Rect size = line_size(current_line, font_size);
                        if(max_height > 0 && current_height + size.h >= 
size_t(max_height))
                                return wrapped_text;
@@ -1007,7 +1022,7 @@
                        if(!first)
                                wrapped_text += '\n';
                        wrapped_text += current_line;
-                       current_line = "";
+                       current_line = format_string;
                        current_height += size.h;
                        line_break = false;
                        first = false;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]