--- fcinit-Original.c 2013-10-11 05:10:18 +0200 +++ fcinit.c 2014-02-15 17:06:23 +0200 @@ -38,15 +38,52 @@ static FcConfig * FcInitFallbackConfig (void) { + FcConfig *config; +#ifdef _WIN32 + FcChar8 buffer[1000]; + int rc; +#endif config = FcConfigCreate (); if (!config) goto bail0; +#ifdef _WIN32 + if (!FcConfigAddConfigDir (config, (FcChar8 *) FC_DEFAULT_FONTS)) + goto bail1; + rc = pGetSystemWindowsDirectory ((LPSTR) buffer, sizeof (buffer) - 20); + if (rc == 0 || rc > sizeof (buffer) - 20) + { + fprintf (stderr, "GetSystemWindowsDirectory failed.\n"); + goto bail1; + } + if (buffer [strlen ((const char *) buffer) - 1] != '\\') + strcat ((char *) buffer, "\\"); + strcat ((char *) buffer, "fonts"); + if (!FcConfigAddFontDir (config, buffer)) + goto bail1; +#else if (!FcConfigAddDir (config, (FcChar8 *) FC_DEFAULT_FONTS)) goto bail1; +#endif + +#ifdef _WIN32 + memset(buffer, '\0', sizeof(buffer)); + rc = GetTempPath (800, (LPSTR) buffer); + if (rc == 0 || rc > 800) + { + fprintf (stderr, "GetTempPath failed.\n"); + goto bail1; + } + if (buffer [strlen ((const char *) buffer) - 1] != '/') + strcat ((char *) buffer, "/"); + strcat ((char *) buffer, "fontconfig/cache"); + if (!FcConfigAddCacheDir (config, (FcChar8 *) buffer)) + goto bail1; +#else if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR)) goto bail1; +#endif return config; bail1: @@ -67,6 +104,7 @@ FcConfig * FcInitLoadOwnConfig (FcConfig *config) { + if (!config) { config = FcConfigCreate (); @@ -81,7 +119,6 @@ FcConfigDestroy (config); return FcInitFallbackConfig (); } - if (config->cacheDirs && config->cacheDirs->num == 0) { FcChar8 *prefix, *p; @@ -125,6 +162,7 @@ FcConfig * FcInitLoadConfig (void) { + return FcInitLoadOwnConfig (NULL); }