Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SpaceAttorney |
I have a custom BBCode effect for my dialogue that changes the color of certain snippets of text based on their context, seen below:
@tool
class_name BBCodePaint
extends RichTextEffect
var bbcode = "paint"
## Internal dictionary of paint tags and their default color associations.
var tags : Dictionary = {
"default": Color("#1a1817"),
"thought": Color("#4d4a49"),
}
func _process_custom_fx(char_fx):
# Grab tag, if applicable.
var tag = char_fx.env.get("tag", "default")
if tags.has(tag):
char_fx.color = tags[tag]
return true
else:
return false
(for those wondering, the reason I’m using this and not the normal [color] tag is so I can change the context/color mappings in this script and have all dialogue update automatically)
The problem is that when I use this code in a RichTextLabel, the font starts to render incorrectly. Here is a comparison of the results, compared to the results when I just use the [color] tag to change to the same color:
This doesn’t occur if I use the engine’s default font. It also didn’t occur in Godot 3 when I used the same code with the same pixel font.