Closed MartinHaeusler closed 7 months ago
This can be done with 3 lines of code, so why not.
@bruvzg wow, thanks, that was probably the fastest fix in history :D Looking forward to it, this will make my life in the editor a lot easier!
Implemented by https://github.com/godotengine/godot/pull/90405.
@bruvzg @akien-mga is it possible that this PR wasn't included in 4.2.2.stable?
is it possible that this PR wasn't included in 4.2.2.stable?
It was not included and probably will not be included in any future 4.2.x (there's no cherrypick 4.2
label).
4.2 only receive bug fixes, not new features, see Godot release policy.
Describe the project you are working on
A card game which uses TrueType fonts for rendering icons (e.g. FontAwesome and others).
Describe the problem or limitation you are having in your project
TrueType fonts which offer icon glyphs bind to specific unicode keys. For example, the unicode
F004
is the :heart: icon in FontAwesome. Currently, the only way to get these into the game via a RichTextLabel is to copy the glyph straight into the editor, which is cumbersome for several reasons:Here you can see it in action (the "weird character" is F004, the heart):
... which translates in-game to:
In-game it looks nice. In the editor, it's borderline unusable.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
It would be awesome if we could add arbitrary unicode code points in BBcode via their hex code. For instance, all of the following variations would be fine by me:
[uni]F004[/uni]
[uni=F004]
\uF004
The BBCode interpreter would then recognize these tokens and translate them to the proper code point. In my example above, the "weird character" in the input (in the editor) would be replaced by one of the variations presented above, while the output in the game would remain the same.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
There's already a parser in place for BBCode, it would need to recognize an additional kind of token. I could imagine that this also affects the computation of line widths for word wrap and related features, but otherwise it should have no side effects.
If this enhancement will not be used often, can it be worked around with a few lines of script?
When assigning text programmatically from GDScript or C#, the
\uF004
syntax can be used already. However, this only works because the programming language translates the glyph and is therefore limited to strings that come from the programming language. My proposal would also work for "static" strings which are managed directly in the editor.Is there a reason why this should be core and not an add-on in the asset library?
I think unicode interpretation is a central feature of any RichTextLabel.