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.
This commit is contained in:
Dennis Schridde 2008-05-03 19:45:31 -07:00 committed by Keith Packard
parent ae6fac0802
commit 6d65081e35
2 changed files with 42 additions and 6 deletions

View File

@ -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");

View File

@ -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);