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

[Complex Text Layouts: 3/4] Rich text output / input, RichTextLabel refactoring. #1182

Closed
bruvzg opened this issue Jul 10, 2020 · 2 comments
Closed

Comments

@bruvzg
Copy link
Member

bruvzg commented Jul 10, 2020

This proposal is follow up to #4, to get some community feedback/preferences on a specific parts of CTL support implementation.

Describe the project you are working on:
The Godot Engine


Describe the problem or limitation you are having in your project:

Currently, the only way to output rich text is RichTextLabel / "BBCode", outputting CTL aware text requires its integration with the BiDi/shaping engine.


Describe the feature / enhancement and how it helps to overcome the problem or limitation:

🔹 Complex text is context dependent and to display it correctly whole paragraphs of the text should be passed to the BiDi/shaping engine at once (and if the paragraph contains segments using different fonts this information is required during shaping too).

🔹 Inline images and table are part of the text, they can affect its processing and should be accounted during BiDi/shaping as well (only it's position in the string is relevant).

🔹 After breaking paragraph into the lines, each line should be additionally processed by the BiDi/shaping engine. (Order of line parts can change).


Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

Rich text representation?
🔹 Keep it to RichTextLabel only, and handle CTL in the control itself using low-level functions.

🔹 "BBCode" processing can be fully moved to the shaping engine.

There's no clear paragraph separation (might be changed by adding

tag, or some other rules, like double new lines) and reshaping whole large text on each change can be slow.

🔹 Some intermediate implementation can be used (which will be accessible outside RichTextLabel, and won't need to handle RichTextLabel specific tasks like tables and hyperlinks).

AttributedString/Spannable` (as implemented in godot_tl module).

🔹 Something else?

Do we need rich text output outside RTL?

Do we need rich text WYSIWYG editing capabilities?


If this enhancement will not be used often, can it be worked around with a few lines of script?:
It will be used by RichTextLabel controls and maybe in other ways to output/input formatted text.

Is there a reason why this should be core and not an add-on in the asset library?:
RichTextLabel is part of core, used by editor.

@stijn-h
Copy link

stijn-h commented Jul 11, 2020

Do we need rich text output outside RTL?

Being able to use multiple fonts to draw text could be desirable for certain items.

See these examples for search results in Godot, Sublime Text and VS Code

qo_godot

qo_subl

qo_vs

This can be used for highlighting character matches in search results (in ItemList/Tree, Inspector etc.) or scaling certain text down or up to create contrast. Using Control nodes such as Containers and Labels does allow multiple fonts (Project Manager), but it is expensive and doesn't allow character highlighting.

I understand these classes are deliberately kept simple, but it seems like the functionality would be common between multiple classes.

Possibly related use cases: godotengine/godot#27910 (TextEdit) and #367.

@bruvzg
Copy link
Member Author

bruvzg commented Dec 14, 2020

Proposal is implemented in godotengine/godot#41100 and godotengine/godot#42595.

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

No branches or pull requests

3 participants