From 02a9377da0da185685896138316c3bdb0623e021 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 29 Oct 2021 17:15:22 -0700 Subject: UI: Default Fonts Folder for Mac and Linux Initial defaults for userdef->fontdir for Mac and Linux. See D12802 for more details. Differential Revision: https://developer.blender.org/D12802 Reviewed by Campbell Barton --- source/blender/blenkernel/intern/appdir.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index ce4ab8a4ba1..fb6656a4b1c 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -259,23 +259,24 @@ bool BKE_appdir_folder_caches(char *r_path, const size_t path_len) /** * Gets a good default directory for fonts. */ -bool BKE_appdir_font_folder_default( - /* This parameter can only be `const` on non-windows platforms. - * NOLINTNEXTLINE: readability-non-const-parameter. */ - char *dir) +bool BKE_appdir_font_folder_default(char *dir) { - bool success = false; #ifdef WIN32 wchar_t wpath[FILE_MAXDIR]; - success = SHGetSpecialFolderPathW(0, wpath, CSIDL_FONTS, 0); - if (success) { + if (SHGetSpecialFolderPathW(0, wpath, CSIDL_FONTS, 0)) { wcscat(wpath, L"\\"); BLI_strncpy_wchar_as_utf8(dir, wpath, FILE_MAXDIR); + return (BLI_exists(dir)); } + return false; +#elif defined(__APPLE__) + const char *home = BLI_getenv("HOME"); + BLI_snprintf(dir, FILE_MAXDIR, "%s/Library/Fonts/", home); + return (BLI_exists(dir)); +#else + BLI_strncpy(dir, "/usr/share/fonts/", FILE_MAXDIR); + return (BLI_exists(dir)); #endif - /* TODO: Values for other platforms. */ - UNUSED_VARS(dir); - return success; } /** \} */ -- cgit v1.2.3