Open KoBeWi opened 1 week ago
However unfolding visible_characters does not work that well with autowrap. The word will start appearing at the end of line and then jump to the next line as it gets wrapped. It looks very jarring and many people reported this problem when playtesting my game.
The problem is that the only way to fix it is changing visible_characters_behavior from the default Characters Before Shaping to Characters After Shaping. This makes get_line_count() always return all lines, even if hidden by visible_characters.
These looks like expected behavior, in Characters Before Shaping
mode, "hidden" lines do not exist at all, text is trimmed before processing (changing visible_characters
should be equivalent of typing text in). So RTL has no idea how many line wraps there will be (\r
counts as forced line wrap), but still count all paragraphs (\n
is used as paragraph separator).
Not sure if it can be fully fixed, but:
\r\n
probably should be used as paragraph separator as well (customizable, maybe add separate paragraph spacing as well).We may also consider changing default mode to VC_CHARS_AFTER_SHAPING
or VC_GLYPHS_AUTO
, since it's probably more expected behavior for a lot of cases.
Tested versions
4.3 4.4 dev5
System information
Windows 10.0.19045 - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 32.0.15.6603) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 threads)
Issue description
I'm using RichTextLabel for my dialogue system. I rely on
get_line_count()
returning only lines not hidden byvisible_characters
.However unfolding
visible_characters
does not work that well with autowrap. The word will start appearing at the end of line and then jump to the next line as it gets wrapped. It looks very jarring and many people reported this problem when playtesting my game.The problem is that the only way to fix it is changing
visible_characters_behavior
from the default Characters Before Shaping to Characters After Shaping. This makesget_line_count()
always return all lines, even if hidden byvisible_characters
.Though while testing this, I discovered another weird thing about
get_line_count()
- thevisible_characters
interaction only works if lines end with\r
. If lines end with\n
, the behavior is consistent betweenvisible_characters_behavior
, i.e. it always returns all lines 🙃Steps to reproduce
Run this scripts. You will see 1, 2, 3... 10 being printed. If you change
visible_characters_behavior
, it will always print 10.Minimal reproduction project (MRP)
N/A