[Bf-blender-cvs] [02a9377da0d] master: UI: Default Fonts Folder for Mac and Linux
Harley Acheson
noreply at git.blender.org
Sat Oct 30 02:16:11 CEST 2021
Commit: 02a9377da0da185685896138316c3bdb0623e021
Author: Harley Acheson
Date: Fri Oct 29 17:15:22 2021 -0700
Branches: master
https://developer.blender.org/rB02a9377da0da185685896138316c3bdb0623e021
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
===================================================================
M source/blender/blenkernel/intern/appdir.c
===================================================================
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;
}
/** \} */
More information about the Bf-blender-cvs
mailing list