From 7e1203e4a7aa7373d5ed3e7756ab4ebd7fd24a39 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 8 Apr 2004 19:00:38 +0000 Subject: [PATCH] fix repeated newlines --- panda/src/text/textAssembler.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 484d626be6..fad3af9bf6 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -729,10 +729,6 @@ assemble_paragraph(TextAssembler::TextString::const_iterator si, } // Advance to the next line. - if (si != send) { - // Skip past the newline. - ++si; - } num_rows++; } @@ -760,7 +756,7 @@ assemble_row(TextAssembler::TextString::const_iterator &si, float xpos = 0.0f; align = TextProperties::A_left; - while (si != send && (*si)._character != '\n') { + while (si != send) { wchar_t character = (*si)._character; const TextProperties *properties = (*si)._properties; @@ -768,13 +764,20 @@ assemble_row(TextAssembler::TextString::const_iterator &si, nassertv(font != (TextFont *)NULL); // We get the row's alignment property from that of the last - // character to be placed in the row. + // character to be placed in the row (or the newline character). align = properties->get_align(); // And the height of the row is the maximum of all the fonts used // within the row. line_height = max(line_height, font->get_line_height()); + if (character == '\n') { + // The newline character marks the end of the row. + row_width = xpos; + ++si; + return; + } + if (character == ' ') { // A space is a special case. xpos += font->get_space_advance();