diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index a43b708db52..d872dc67dcb 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -281,22 +281,29 @@ bool BKE_appdir_folder_caches(char *r_path, const size_t path_len) */ bool BKE_appdir_font_folder_default(char *dir) { + char test_dir[FILE_MAXDIR]; + test_dir[0] = '\0'; + #ifdef WIN32 wchar_t wpath[FILE_MAXDIR]; if (SHGetSpecialFolderPathW(0, wpath, CSIDL_FONTS, 0)) { wcscat(wpath, L"\\"); - BLI_strncpy_wchar_as_utf8(dir, wpath, FILE_MAXDIR); - return (BLI_exists(dir)); + BLI_strncpy_wchar_as_utf8(test_dir, wpath, sizeof(test_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)); + if (home) { + BLI_path_join(test_dir, sizeof(test_dir), home, "Library", "Fonts", NULL); + } #else - BLI_strncpy(dir, "/usr/share/fonts/", FILE_MAXDIR); - return (BLI_exists(dir)); + STRNCPY(test_dir, "/usr/share/fonts"); #endif + + if (test_dir[0] && BLI_exists(test_dir)) { + BLI_strncpy(dir, test_dir, FILE_MAXDIR); + return true; + } + return false; } /** \} */