diff -urp fontconfig-2.8.0.orig/src/fccache.c fontconfig-2.8.0/src/fccache.c --- fontconfig-2.8.0.orig/src/fccache.c 2009-11-16 18:24:52 +0100 +++ fontconfig-2.8.0/src/fccache.c 2010-04-08 04:32:56 +0200 @@ -32,9 +32,6 @@ #if defined(HAVE_MMAP) || defined(__CYGWIN__) # include # include -#elif defined(_WIN32) -# define _WIN32_WINNT 0x0500 -# include #endif #ifndef O_BINARY diff -urp fontconfig-2.8.0.orig/src/fcint.h fontconfig-2.8.0/src/fcint.h --- fontconfig-2.8.0.orig/src/fcint.h 2009-11-16 23:46:18 +0100 +++ fontconfig-2.8.0/src/fcint.h 2010-04-08 04:59:03 +0200 @@ -55,6 +55,12 @@ #endif #ifdef _WIN32 +#define _WIN32_WINNT 0x0500 +#define WIN32_LEAN_AND_MEAN +#define STRICT +#include +#undef STRICT +#include #define FC_SEARCH_PATH_SEPARATOR ';' #else #define FC_SEARCH_PATH_SEPARATOR ':' @@ -535,6 +541,11 @@ FcDirCacheReference (FcCache *cache, int #ifdef _WIN32 FcPrivate int FcStat (const char *file, struct stat *statb); + +typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT); +typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR); +extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory; +extern pfnSHGetFolderPathA pSHGetFolderPathA; #else #define FcStat stat #endif diff -urp fontconfig-2.8.0.orig/src/fcxml.c fontconfig-2.8.0/src/fcxml.c --- fontconfig-2.8.0.orig/src/fcxml.c 2009-11-16 23:46:18 +0100 +++ fontconfig-2.8.0/src/fcxml.c 2010-04-08 05:18:16 +0200 @@ -52,14 +52,6 @@ #endif /* ENABLE_LIBXML2 */ -#ifdef _WIN32 -#define _WIN32_WINNT 0x0500 -#define STRICT -#include -#undef STRICT -#include -#endif - static void FcExprDestroy (FcExpr *e); @@ -2075,11 +2067,7 @@ FcEndElement(void *userData, const XML_C { int rc; data = buffer; -#if _WIN32_WINNT >= 0x0500 - rc = GetSystemWindowsDirectory (buffer, sizeof (buffer) - 20); -#else - rc = GetWindowsDirectory (buffer, sizeof (buffer) - 20); -#endif + rc = pGetSystemWindowsDirectory (buffer, sizeof (buffer) - 20); if (rc == 0 || rc > sizeof (buffer) - 20) { FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed"); @@ -2129,6 +2117,30 @@ FcEndElement(void *userData, const XML_C strcat (data, "\\"); strcat (data, "fontconfig\\cache"); } + else if (strcmp (data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0) + { + char szFPath[MAX_PATH + 1]; + size_t len; + FcStrFree (data); + + if (!(pSHGetFolderPathA && SUCCEEDED(pSHGetFolderPathA(NULL, /* CSIDL_LOCAL_APPDATA */ 28, NULL, 0, szFPath)))) + { + FcConfigMessage (parse, FcSevereError, "SHGetFolderPathA failed"); + break; + } + + strncat(szFPath, "\\MPlayer", MAX_PATH - 1 - strlen(szFPath)); + len = strlen(szFPath) + 1; + data = malloc(len); + if (!data) + { + FcConfigMessage (parse, FcSevereError, "out of memory"); + break; + } + + FcMemAlloc (FC_MEM_STRING, len); + strncpy(data, szFPath, len); + } #endif if (!FcStrUsesHome (data) || FcConfigHome ()) { @@ -2436,6 +2448,11 @@ bail0: return ret || !complain; } +#ifdef _WIN32 +pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL; +pfnSHGetFolderPathA pSHGetFolderPathA = NULL; +#endif + FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *name, @@ -2455,6 +2472,22 @@ FcConfigParseAndLoad (FcConfig *conf #else void *buf; #endif + +#ifdef _WIN32 + if (!pGetSystemWindowsDirectory) + { + HMODULE hk32 = GetModuleHandleA("kernel32.dll"); + if (!(pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetProcAddress(hk32, "GetSystemWindowsDirectoryA"))) + pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetWindowsDirectory; + } + if (!pSHGetFolderPathA) + { + HMODULE hSh = LoadLibraryA("shfolder.dll"); + /* will check for it later */ + if (hSh) + pSHGetFolderPathA = (pfnSHGetFolderPathA) GetProcAddress(hSh, "SHGetFolderPathA"); + } +#endif filename = FcConfigFilename (name); if (!filename)