Godot Version 4.1

Take a look at my simple code snippet:

var font =
var robotoFile = load("res://Roboto-Light.ttf")
var fontSize = 24
var halfWidthFont
var heightFont
var StringValue = "Hello World!"

func _ready():
	pass # Replace with function body.
	font.resource_path = "res://"
	font.fixed_size = fontSize
	halfWidthFont = font.get_string_size(StringValue).x / 2
	heightFont = font.get_height()

I posted the last post to check after the bug worked. And only print(heightFont): returns 0. I change it to font.get_height(20) or font.get_height(fontSize) but it still returns 0. heightFont I wanted to use to calculate the height so that I can correctly draw the text on the screen.

You need to load() or preload() the resource, setting its resource_path won’t load it.