[Fontconfig] fontconfig: Branch 'master'
Keith Packard
keithp at kemper.freedesktop.org
Sat May 3 19:45:37 PDT 2008
src/fccfg.c | 26 +++++++++++++++++++++-----
src/fcxml.c | 22 +++++++++++++++++++++-
2 files changed, 42 insertions(+), 6 deletions(-)
New commits:
commit 6d65081e35fc1ffae1212f173853b0693645192e
Author: Dennis Schridde <lindevel at gmx.net>
Date: Sat May 3 19:45:31 2008 -0700
Proper config path for static libraries in win32
Since fontconfig didn't have special handling for paths in static Windows
libraries, I've created a patch which should fix this.
Basically it does this:
fccfg.c:
If fontconfig_path was uninitialised it tries to get the directory the exe is
in and uses a fonts/ dir inside that.
fcxml.c:
In case the fonts.conf lists a <dir>CUSTOMFONTDIR</dir>, it searches for a
fonts/ directory where the exe is located.
diff --git a/src/fccfg.c b/src/fccfg.c
index ed620a0..853eb7f 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -1520,10 +1520,16 @@ FcConfigSubstitute (FcConfig *config,
return FcConfigSubstituteWithPat (config, p, 0, kind);
}
-#if defined (_WIN32) && (defined (PIC) || defined (DLL_EXPORT))
+#if defined (_WIN32)
+
+# define WIN32_LEAN_AND_MEAN
+# define WIN32_EXTRA_LEAN
+# include <windows.h>
static FcChar8 fontconfig_path[1000] = "";
+# if (defined (PIC) || defined (DLL_EXPORT))
+
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
@@ -1561,12 +1567,12 @@ DllMain (HINSTANCE hinstDLL,
return TRUE;
}
+# endif /* !PIC */
+
#undef FONTCONFIG_PATH
#define FONTCONFIG_PATH fontconfig_path
-#else /* !(_WIN32 && PIC) */
-
-#endif /* !(_WIN32 && PIC) */
+#endif /* !_WIN32 */
#ifndef FONTCONFIG_FILE
#define FONTCONFIG_FILE "fonts.conf"
@@ -1651,6 +1657,16 @@ FcConfigGetPath (void)
}
}
+#ifdef _WIN32
+ if (fontconfig_path[0] == '\0')
+ {
+ if(!GetModuleFileName(NULL, fontconfig_path, sizeof(fontconfig_path)))
+ goto bail1;
+ char *p = strrchr (fontconfig_path, '\\');
+ if (p) *p = '\0';
+ strcat (fontconfig_path, "\\fonts");
+ }
+#endif
dir = (FcChar8 *) FONTCONFIG_PATH;
path[i] = malloc (strlen ((char *) dir) + 1);
if (!path[i])
@@ -1707,7 +1723,7 @@ FcChar8 *
FcConfigFilename (const FcChar8 *url)
{
FcChar8 *file, *dir, **path, **p;
-
+
if (!url || !*url)
{
url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
diff --git a/src/fcxml.c b/src/fcxml.c
index 1910306..a2cc02e 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -2058,7 +2058,27 @@ FcEndElement(void *userData, const XML_Char *name)
break;
}
#ifdef _WIN32
- if (strcmp (data, "WINDOWSFONTDIR") == 0)
+ if (strcmp (data, "CUSTOMFONTDIR") == 0)
+ {
+ FcStrFree (data);
+ data = malloc (1000);
+ if (!data)
+ {
+ FcConfigMessage (parse, FcSevereError, "out of memory");
+ break;
+ }
+ FcMemAlloc (FC_MEM_STRING, 1000);
+ if(!GetModuleFileName(NULL, data, 1000))
+ {
+ FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
+ FcStrFree (data);
+ break;
+ }
+ char *p = strrchr (data, '\\');
+ if (p) *p = '\0';
+ strcat (data, "\\fonts");
+ }
+ else if (strcmp (data, "WINDOWSFONTDIR") == 0)
{
int rc;
FcStrFree (data);
More information about the Fontconfig
mailing list