From a5c3e2e37e6d3c568e96f2e64a3116c89788bdf1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 3 Apr 2019 23:01:56 +1100 Subject: [PATCH] Get actual system directory instead of hardcoding to C:/Windows --- src/Platform.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Platform.c b/src/Platform.c index da2deb77b..834a5838b 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -1242,10 +1242,21 @@ static void* FT_ReallocWrapper(FT_Memory memory, long cur_size, long new_size, v #define FONT_CACHE_FILE "fontscache.txt" static void Font_Init(void) { #if defined CC_BUILD_WIN - const static String dirs[2] = { - String_FromConst("C:/Windows/Fonts"), - String_FromConst("C:/WINNT/Fonts") - }; + char winFolder[FILENAME_SIZE]; + TCHAR winTmp[FILENAME_SIZE]; + + /* System folder path may not be C:/Windows */ + String dirs[1]; + String_InitArray(dirs[0], winFolder); + + UINT winLen = GetSystemWindowsDirectory(winTmp, FILENAME_SIZE); + if (winLen) { + Platform_DecodeString(&dirs[0], winTmp, winLen); + } else { + String_AppendConst(&dirs[0], "C:/Windows"); + } + String_AppendConst(&dirs[0], "/fonts"); + #elif defined CC_BUILD_NETBSD const static String dirs[3] = { String_FromConst("/usr/X11R7/lib/X11/fonts"),