Ver Fonte

fix repeated newlines

David Rose há 22 anos atrás
pai
commit
7e1203e4a7
1 ficheiros alterados com 9 adições e 6 exclusões
  1. 9 6
      panda/src/text/textAssembler.cxx

+ 9 - 6
panda/src/text/textAssembler.cxx

@@ -729,10 +729,6 @@ assemble_paragraph(TextAssembler::TextString::const_iterator si,
     }
     }
 
 
     // Advance to the next line.
     // Advance to the next line.
-    if (si != send) {
-      // Skip past the newline.
-      ++si;
-    }
     num_rows++;
     num_rows++;
   }
   }
 
 
@@ -760,7 +756,7 @@ assemble_row(TextAssembler::TextString::const_iterator &si,
   float xpos = 0.0f;
   float xpos = 0.0f;
   align = TextProperties::A_left;
   align = TextProperties::A_left;
 
 
-  while (si != send && (*si)._character != '\n') {
+  while (si != send) {
     wchar_t character = (*si)._character;
     wchar_t character = (*si)._character;
     const TextProperties *properties = (*si)._properties;
     const TextProperties *properties = (*si)._properties;
 
 
@@ -768,13 +764,20 @@ assemble_row(TextAssembler::TextString::const_iterator &si,
     nassertv(font != (TextFont *)NULL);
     nassertv(font != (TextFont *)NULL);
 
 
     // We get the row's alignment property from that of the last
     // 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();
     align = properties->get_align();
 
 
     // And the height of the row is the maximum of all the fonts used
     // And the height of the row is the maximum of all the fonts used
     // within the row.
     // within the row.
     line_height = max(line_height, font->get_line_height());
     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 == ' ') {
     if (character == ' ') {
       // A space is a special case.
       // A space is a special case.
       xpos += font->get_space_advance();
       xpos += font->get_space_advance();