1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Fix crash when the theme has no default font, by using Godot's fallback font instead

This commit is contained in:
Emmanouil Papadeas 2024-07-14 16:08:18 +03:00
parent 5d06af39b2
commit bcbd0ea7da
8 changed files with 13 additions and 7 deletions

View file

@ -88,3 +88,9 @@ func change_icon_colors() -> void:
texture.modulate = Global.modulate_icon_color
if node.disabled:
texture.modulate.a = 0.5
func get_font() -> Font:
if Global.control.theme.has_default_font():
return Global.control.theme.default_font
return ThemeDB.fallback_font

View file

@ -210,7 +210,7 @@ func _set_type(value: Type) -> void:
Type.TEXT:
node3d_type = MeshInstance3D.new()
var mesh := TextMesh.new()
mesh.font = Global.control.theme.default_font
mesh.font = Themes.get_font()
mesh.text = "Sample"
node3d_type.mesh = mesh
Type.DIR_LIGHT:

View file

@ -219,7 +219,7 @@ func _draw() -> void:
draw_circle(proj_back_local_scale, SCALE_CIRCLE_RADIUS, Color.BLUE)
# Draw X, Y, Z characters on top of the scale circles
var font: Font = Global.control.theme.default_font
var font := Themes.get_font()
var font_height := font.get_height()
var char_position := Vector2(-font_height, font_height) * CHAR_SCALE / 4 * draw_scale
draw_set_transform(gizmos_origin + char_position, 0, draw_scale * CHAR_SCALE)

View file

@ -10,7 +10,7 @@ var rect_bounds: Rect2i
func _ready() -> void:
font = Global.control.theme.default_font
font = Themes.get_font()
func update_measurement(mode_idx := Global.MeasurementMode.NONE) -> void:

View file

@ -5,7 +5,7 @@ enum Types { HORIZONTAL, VERTICAL }
const INPUT_WIDTH := 4
var font: Font = Global.control.theme.default_font
var font := Themes.get_font()
var has_focus := true
var mouse_pos := Vector2.ZERO
var type := Types.HORIZONTAL

View file

@ -26,7 +26,7 @@ func _gui_input(event: InputEvent) -> void:
# Code taken and modified from Godot's source code
func _draw() -> void:
var font: Font = Global.control.theme.default_font
var font := Themes.get_font()
var transform := Transform2D()
var ruler_transform := Transform2D()
var major_subdivide := Transform2D()

View file

@ -26,7 +26,7 @@ func _gui_input(event: InputEvent) -> void:
# Code taken and modified from Godot's source code
func _draw() -> void:
var font: Font = Global.control.theme.default_font
var font := Themes.get_font()
var transform := Transform2D()
var ruler_transform := Transform2D()
var major_subdivide := Transform2D()

View file

@ -32,7 +32,7 @@ func _draw() -> void:
draw_set_transform(_offset + scaled_rect.position, 0, Vector2.ONE)
# var font: Font = Control.new().get_font("font")
# replace with font used by pixelorama
var font: Font = Global.control.theme.default_font
var font := Themes.get_font()
var font_height := font.get_height()
draw_string(font, Vector2(1, font_height), str(i))
draw_set_transform(_offset, 0, Vector2.ONE)