瀏覽代碼

text: fix is_whitespace() assertion when invalid chars are included

rdb 7 年之前
父節點
當前提交
5c90f64182
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 4 3
      panda/src/text/textAssembler.cxx
  2. 7 0
      tests/text/test_text_assemble.py

+ 4 - 3
panda/src/text/textAssembler.cxx

@@ -1626,10 +1626,11 @@ assemble_row(TextAssembler::TextRow &row,
       }
 
       if (first_glyph != (TextGlyph *)NULL) {
-        assert(!first_glyph->is_whitespace());
         advance = first_glyph->get_advance() * advance_scale;
-        swap(placement._glyph, first_glyph);
-        placed_glyphs.push_back(placement);
+        if (!first_glyph->is_whitespace()) {
+          swap(placement._glyph, first_glyph);
+          placed_glyphs.push_back(placement);
+        }
       }
 
       // Check if there is a second glyph to create a hacky ligature or some

+ 7 - 0
tests/text/test_text_assemble.py

@@ -0,0 +1,7 @@
+from panda3d import core
+
+def test_text_assemble_null():
+    # Tests that no is_whitespace() assert occurs
+    assembler = core.TextAssembler(core.TextEncoder())
+    assembler.set_wtext(u"\0test")
+    assembler.assemble_text()