Troubles with RichTextLabel

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By professorik

Hello! I am trying to make a scoreboard table using RichTextLabel.
There is my code:

func set_result(rows: Array) -> void:
$RichTextLabel.push_table(3)
for row in rows: # Add table values
	for key in row:
		$RichTextLabel.push_cell()
		$RichTextLabel.add_text(key)
		$RichTextLabel.pop()

I can see the table, but in the zero line, the text is superimposed on each other. How to fix it?

:bust_in_silhouette: Reply From: jgodfrey

Your code seems to work as expected for me. I tested it like this:

func _ready():
	var a = [["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["j", "k", "l"]]
	set_result(a)

func set_result(rows: Array) -> void:
	$RichTextLabel.push_table(3)
	for row in rows: # Add table values
		for key in row:
			$RichTextLabel.push_cell()
			$RichTextLabel.add_text(key)
			$RichTextLabel.pop()

That generates a table containing 4 rows (the 4 sub-arrays) and 3 columns. I don’t see any overlapping text…

Ok, you are right. But I think you did it with the default background color and RichTextLabel. I found that overlapping text is “shadow”, so I just set Custom Colors -> Font Color Shadow with a transparent color and it works! Maybe you can suggest a better solution. Anyway, thanks!

professorik | 2020-11-09 21:02

Hmmm… Yeah, activating the shadow color does cause some strange results. Really, that feels like a bug to me, but I’m not familiar with the details of the RichTextLabel node so I’m not 100% sure.

However, rather than setting the shadow color to transparent, you can simply not use the shadow color by unchecking Custom Colors | Font Color Shadow. At least, that works as expected here…

jgodfrey | 2020-11-09 21:51