@@ -7,6 +7,9 @@ signal shader_copied(file_path: String)
7
7
8
8
const BACKUPS_DIRECTORY := "user://backups"
9
9
const SHADERS_DIRECTORY := "user://shaders"
10
+ const FONT_FILE_EXTENSIONS : PackedStringArray = [
11
+ "ttf" , "otf" , "woff" , "woff2" , "pfb" , "pfm" , "fnt" , "font"
12
+ ]
10
13
11
14
var current_session_backup := ""
12
15
var preview_dialog_tscn := preload ("res://src/UI/Dialogs/ImportPreviewDialog.tscn" )
@@ -87,6 +90,15 @@ func handle_loading_file(file: String, force_import_dialog_on_images := false) -
87
90
shader_copied .emit (new_path )
88
91
elif file_ext == "mp3" or file_ext == "wav" : # Audio file
89
92
open_audio_file (file )
93
+ elif file_ext in FONT_FILE_EXTENSIONS :
94
+ var font_file := open_font_file (file )
95
+ if font_file .data .is_empty ():
96
+ return
97
+ if not DirAccess .dir_exists_absolute (Global .FONTS_DIR_PATH ):
98
+ DirAccess .make_dir_absolute (Global .FONTS_DIR_PATH )
99
+ var new_path := Global .FONTS_DIR_PATH .path_join (file .get_file ())
100
+ DirAccess .copy_absolute (file , new_path )
101
+ Global .loaded_fonts .append (font_file )
90
102
elif file_ext == "ora" :
91
103
open_ora_file (file )
92
104
elif file_ext == "kra" :
@@ -1008,6 +1020,15 @@ func open_audio_file(path: String) -> void:
1008
1020
Global .animation_timeline .add_layer (new_layer , project )
1009
1021
1010
1022
1023
+ func open_font_file (path : String ) -> FontFile :
1024
+ var font_file := FontFile .new ()
1025
+ if path .to_lower ().get_extension () == "fnt" or path .to_lower ().get_extension () == "font" :
1026
+ font_file .load_bitmap_font (path )
1027
+ else :
1028
+ font_file .load_dynamic_font (path )
1029
+ return font_file
1030
+
1031
+
1011
1032
# Based on https://www.openraster.org/
1012
1033
func open_ora_file (path : String ) -> void :
1013
1034
var zip_reader := ZIPReader .new ()
0 commit comments