0 votes

Hi everyone,

I have a clock ticking in a RichTextLabel, hours, minutes and seconds.

extends RichTextLabel

var date_time
var hour
var minute
var second
export var twentyfour = true

func _process(_delta):
    date_time = OS.get_datetime()

    hour = date_time.get("hour")
    minute = date_time.get("minute")
    second = date_time.get("second")

    if(second<10):
        second = "0" + str(second)
    if(minute<10):
        minute = "0" + str(minute)

    set_text(str(hour) + ":" + str(minute) + ":" + str(second))

I'd like to have the seconds-digits be written smaller than the rest.
Is there any simple way to apply a custom font-size to them? (I'd assume bbcode might work, but how could I attach it to the seconds only?)

Godot version 3.2.3
in Engine by (365 points)

1 Answer

0 votes

I never tried this but according to documentation(link) you could use this with bbcode:

[font=<path>]{text}[/font] # Use custom font at <path> for {text}.

and you could have different fonts with different font sizes (or a dynamic font and change its size).
This is one solution, a much simpler solution is have three different labels with different font.

by (106 points)

Indeed, three different labels would work as well, didn't think of this!

Right now I'm not sure how to correctly implement that path... I set up an export(String, FILE) var smallerFontPath but I can't seem to have it included. Where do I have to put my path?
(By the way, the code [font=<path>]{text}[/font] is currently leading to the error message Error parsing expression, misplaced: '<')

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.