From 753c8eae553fedf0b74180c8bf76b347b6ef4a9e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 4 Oct 2023 11:28:42 -0700 Subject: [PATCH] UI: Interface Font Selection When selecting fonts for the interface, show thumbnails and start in the user-specified fonts directory --- .../editors/space_buttons/buttons_ops.cc | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/blender/editors/space_buttons/buttons_ops.cc b/source/blender/editors/space_buttons/buttons_ops.cc index 2bea5abda00..f10ac59644f 100644 --- a/source/blender/editors/space_buttons/buttons_ops.cc +++ b/source/blender/editors/space_buttons/buttons_ops.cc @@ -20,6 +20,7 @@ #include "BLT_translation.h" +#include "BKE_appdir.h" #include "BKE_context.h" #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); -- 2.30.2