0 votes

I'm new to Godot so I apologize if I don't word things correctly or if my question has a simple answer. I'm trying to get the game to change fonts while its running, but whenever I try and change it using addfontoverride the text disappears. This is roughly what I'm doing:

onready var menu = $Menu
var font_array = []
var target = 0

func _ready():

func dir_contents(path):
  var dir = Directory.new()
  if dir.open(path) == OK:
    var file_name = dir.get_next()
    while file_name != "":
      if dir.current_is_dir():
        var temp_font = "res://fonts/" + file_name
        var dynamic_font = DynamicFont.new()
        dynamic_font.size = 16
        dynamic_font.font_data = load(temp_font)

func _on_Button_input(event):
  target += 1
  if target > len(font_array) - 1:
    target = 0
  menu.add_font_override("normal_font", font_array[target])

All the fonts I'm using are in 'res://fonts/'. I currently only have 3 fonts, two being .ttf and one being .TTF, though the same problem happens even if I remove the .TTF file.

Godot version 3.4
in Engine by (12 points)

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.