From 5c90f64182031d924179aab66cef9edb6f83cfe2 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 20:48:58 +0100 Subject: [PATCH] text: fix is_whitespace() assertion when invalid chars are included --- panda/src/text/textAssembler.cxx | 7 ++++--- tests/text/test_text_assemble.py | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/text/test_text_assemble.py diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index a10179db04..49c507dafd 100644 --- a/panda/src/text/textAssembler.cxx +++ b/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 diff --git a/tests/text/test_text_assemble.py b/tests/text/test_text_assemble.py new file mode 100644 index 0000000000..959097029c --- /dev/null +++ b/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()