Fix #102714: Interface Font Selection #113259

Merged
Harley Acheson merged 3 commits from Harley/blender:UIFontSelection into main 2023-11-16 22:07:41 +01:00
1 changed files with 26 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "BLT_translation.h"
#include "BKE_appdir.h"
#include "BKE_context.hh"
#include "BKE_main.h"
#include "BKE_report.h"
@ -332,6 +333,31 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
if (!path[0]) {
/* Defaults if the path is empty. */
if (STR_ELEM(
RNA_property_identifier(prop), "font_path_ui", "font_path_ui_mono", "font_directory"))
{
if (!U.fontdir[0]) {
char fonts_dir[FILE_MAXDIR];
BKE_appdir_font_folder_default(fonts_dir, ARRAY_SIZE(fonts_dir));
BLI_path_slash_ensure(fonts_dir, ARRAY_SIZE(fonts_dir));
path = BLI_strdup(fonts_dir);
}
else {
MEM_freeN(path);
path = BLI_strdup(U.fontdir);
}
RNA_boolean_set(op->ptr, "filter_font", true);
RNA_enum_set(op->ptr, "display_type", FILE_IMGDISPLAY);
RNA_enum_set(op->ptr, "sort_method", FILE_SORT_ALPHA);
}
else {
MEM_freeN(path);
path = BLI_strdup(BKE_appdir_folder_default_or_root());
}
}
RNA_string_set(op->ptr, path_prop, path);
MEM_freeN(path);