diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2021-10-30 03:15:22 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2021-10-30 03:15:22 +0300 |
commit | 02a9377da0da185685896138316c3bdb0623e021 (patch) | |
tree | 3b9a97477c64ce7d4e0d02dd62e7ed58023d82fc /source/blender | |
parent | dcdbaf89bd114aaf066cec57bb619b828c159719 (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 21 |
1 files 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; } /** \} */ |