How to change font color through code, without changing text style

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

Using the suggestion in a previous question, I’m using .add_color_override() to change the color of my text through code. The issue is the method also seems to make the text bold and a bit hard to read. I’m wondering why it’s not just changing the color, and if something can be done about it.

In the attached video, look at the top left label that says “ready” before and after the text changes.

func p1_laser_fired():
p1_laser.text = "Charging"
p1_laser.add_color_override("default_color", Color(255,0,0,255))

func p1_laser_ready():
p1_laser.text = "   Ready"
p1_laser.add_color_override("default_color", Color(0,255,0,255))

video

:bust_in_silhouette: Reply From: njamster

The color-component-values range from 0.0 to 1.0. Inserting values greater than 1.0 will result in overbright colors, which, if taken to the extreme, will result in the color bleeding into the texts surrounding - like in your case.

So this will work:

func p1_laser_fired():
    p1_laser.text = "Charging"
    p1_laser.add_color_override("default_color", Color(1,0,0,1))

func p1_laser_ready():
    p1_laser.text = "   Ready"
    p1_laser.add_color_override("default_color", Color(0,1,0,1))

This is the 2nd time in the past few days I’ve forgotten it’s a range from 0.0 to 1.0. Thanks!

TheJollyReaper | 2020-06-21 14:34