Created
March 23, 2011 10:31
-
-
Save Jessidhia/882917 to your computer and use it in GitHub Desktop.
give fontconfig some saner windows behavior and a saner caching behavior too
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur fontconfig-2.8.0-orig/src/fcdir.c fontconfig-2.8.0/src/fcdir.c | |
--- fontconfig-2.8.0-orig/src/fcdir.c 2009-11-16 17:24:52.000000000 +0000 | |
+++ fontconfig-2.8.0/src/fcdir.c 2011-03-23 10:28:31.000000000 +0000 | |
@@ -203,8 +203,22 @@ | |
/* | |
* Scan file files to build font patterns | |
*/ | |
- for (i = 0; i < files->num; i++) | |
+ char buf1[512], buf2[512], pad[512], *str = &buf1[0], *prev = &buf2[0], *tmp; | |
+ int j, diff; | |
+ prev[0] = pad[0] = 0; | |
+ fprintf (stderr, "\n"); | |
+ for (i = 0; i < files->num; i++) { | |
+ // damn your indentation fontconfig | |
+ snprintf (str, 512, "\r[%d/%d] %s", i+1, files->num, files->strs[i]); | |
+ for (diff = strlen (prev) - strlen (str), j = 0; diff > 0; diff--, j++) { | |
+ pad[j] = ' '; | |
+ } | |
+ pad[j] = 0; | |
+ fprintf (stderr, "%s%s", str, pad); | |
+ tmp = str; str = prev; prev = tmp; | |
FcFileScanConfig (set, dirs, blanks, files->strs[i], config); | |
+ } | |
+ fprintf (stderr, "\n"); | |
bail2: | |
FcStrSetDestroy (files); | |
diff -ur fontconfig-2.8.0-orig/src/fcinit.c fontconfig-2.8.0/src/fcinit.c | |
--- fontconfig-2.8.0-orig/src/fcinit.c 2009-11-16 17:24:52.000000000 +0000 | |
+++ fontconfig-2.8.0/src/fcinit.c 2011-03-23 09:59:02.000000000 +0000 | |
@@ -25,6 +25,12 @@ | |
#include "fcint.h" | |
#include <stdlib.h> | |
+#ifdef _WIN32 | |
+#define _WIN32_IE 0x0500 | |
+#include <shlobj.h> | |
+#include <malloc.h> | |
+#endif | |
+ | |
static FcConfig * | |
FcInitFallbackConfig (void) | |
{ | |
@@ -33,12 +39,41 @@ | |
config = FcConfigCreate (); | |
if (!config) | |
goto bail0; | |
+ | |
+#ifdef _WIN32 | |
+ char *buf = malloc (MAX_PATH+1); | |
+ if (!buf) goto bail1; | |
+ if (SHGetFolderPathA (NULL, CSIDL_FONTS|CSIDL_FLAG_CREATE, NULL, | |
+ SHGFP_TYPE_CURRENT, buf) == S_OK) { | |
+ if (!FcConfigAddDir (config, (FcChar8 *) buf)) | |
+ goto bail2; | |
+ } | |
+ | |
+ char *buf2 = malloc (MAX_PATH+1); | |
+ if (!buf) goto bail2; | |
+ if (SHGetFolderPathA (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL, | |
+ SHGFP_TYPE_CURRENT, buf2) == S_OK) { | |
+ if (buf2[strlen(buf2)-1] != '\\') strcat (buf2, "\\"); | |
+ strcat (buf2, "fontconfig"); | |
+ if (!FcConfigAddCacheDir (config, (FcChar8 *) buf2)) | |
+ goto bail3; | |
+ } | |
+#else | |
if (!FcConfigAddDir (config, (FcChar8 *) FC_DEFAULT_FONTS)) | |
goto bail1; | |
if (!FcConfigAddCacheDir (config, (FcChar8 *) FC_CACHEDIR)) | |
goto bail1; | |
+#endif | |
+ | |
return config; | |
+#ifdef _WIN32 | |
+bail3: | |
+ free(buf2); | |
+bail2: | |
+ free(buf); | |
+#endif | |
+ | |
bail1: | |
FcConfigDestroy (config); | |
bail0: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment