extends Node # Enforce a Chinese-capable font for every UI control, including controls # constructed dynamically after their scene has loaded. const UI_FONT: FontFile = preload("res://assets/fonts/msyh.ttc") func _enter_tree() -> void: get_tree().node_added.connect(_on_node_added) _apply_font_recursively(get_tree().root) func _exit_tree() -> void: var node_added_callback := Callable(self, "_on_node_added") if get_tree().node_added.is_connected(node_added_callback): get_tree().node_added.disconnect(node_added_callback) func _on_node_added(node: Node) -> void: _apply_font_recursively(node) func _apply_font_recursively(node: Node) -> void: if node is Control: var control := node as Control control.add_theme_font_override(&"font", UI_FONT) if control is RichTextLabel: control.add_theme_font_override(&"normal_font", UI_FONT) for child in node.get_children(): _apply_font_recursively(child)