Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichTextLabel's visible_characters no longer accounts for words that break over several lines (Complex Text Layouts regression) #53874

Closed
DeeJayLSP opened this issue Oct 16, 2021 · 5 comments · Fixed by #55636

Comments

@DeeJayLSP
Copy link
Contributor

DeeJayLSP commented Oct 16, 2021

Godot version

Godot v4.0.dev.20211015.official [f113dc9]

System information

Kubuntu 21.04

Issue description

This has been found while porting a project from Godot 3 to 4.
Not sure if a bug or intended, but I haven't seen this change stated anywhere and there's no option to behave the other way.

In Godot 3, increasing the value of RichTextLabel's visible_characters starts typing a word that would get out of bounds already in a new line:

v3

In Godot 4, however, it starts typing the word, then moves it to a new line:

v4

This seems annoying for someone who got used the first behavior.

Steps to reproduce

  • Make a RichTextLabel, give it any text long enough to add new lines and set visible characters to 0
  • Assign a timer to increase the value of visible characters.

Repeat the process on the other version

Minimal reproduction project

This file includes tests on v3 and v4.

@DeeJayLSP
Copy link
Contributor Author

DeeJayLSP commented Oct 21, 2021

Likely a side effect of #42595 since it doesn't happen at a point before its merge, and it completely changes how visible_characters work.

@DeeJayLSP
Copy link
Contributor Author

DeeJayLSP commented Oct 23, 2021

I'm not sure, but the new behavior may be checking the amount of visible characters, then assigning a String that subtracts the non-visible characters. I may be wrong, but that's what I see happening on rich_text_label.cpp around line 443.

@malleusinferni
Copy link

It looks like a couple of attempts have been made to fix it, but they don't address the fundamental design flaw in the new shaping/rendering pipeline. For "typewriter text" to work, the text shaping and layout stage must take the entire string as input (including invisible characters) and produce the complete list of renderable glyphs/quads. It's up to the rendering stage to look at visible_characters and pick out substrings of pre-shaped text. Thus, when a game updates visible_characters, it should prompt a redraw, not a full relayout.

The current behavior (ie. taking substrings before shaping) may break horribly on ligatures and combining characters. It ought to be possible to write additional test cases to probe for this.

@Calinou
Copy link
Member

Calinou commented Dec 4, 2021

cc @bruvzg

@Calinou Calinou changed the title Different behavior of RichTextLabel visible_characters RichTextLabel's visible_characters no longer accounts for words that break over several lines Dec 4, 2021
@Calinou Calinou changed the title RichTextLabel's visible_characters no longer accounts for words that break over several lines RichTextLabel's visible_characters no longer accounts for words that break over several lines (Complex Text Layouts regression) Dec 4, 2021
@DeeJayLSP
Copy link
Contributor Author

I think I should mention this: when showing a word so large it gets out of bounds in Godot 3, it somehow breaks the line for everything to show up. On 4 however, it just gets out of bounds as usual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants