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:
parent
ae6fac0802
commit
6d65081e35
26
src/fccfg.c
26
src/fccfg.c
|
@ -1520,10 +1520,16 @@ FcConfigSubstitute (FcConfig *config,
|
||||||
return FcConfigSubstituteWithPat (config, p, 0, kind);
|
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] = "";
|
static FcChar8 fontconfig_path[1000] = "";
|
||||||
|
|
||||||
|
# if (defined (PIC) || defined (DLL_EXPORT))
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
DllMain (HINSTANCE hinstDLL,
|
DllMain (HINSTANCE hinstDLL,
|
||||||
DWORD fdwReason,
|
DWORD fdwReason,
|
||||||
|
@ -1561,12 +1567,12 @@ DllMain (HINSTANCE hinstDLL,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif /* !PIC */
|
||||||
|
|
||||||
#undef FONTCONFIG_PATH
|
#undef FONTCONFIG_PATH
|
||||||
#define FONTCONFIG_PATH fontconfig_path
|
#define FONTCONFIG_PATH fontconfig_path
|
||||||
|
|
||||||
#else /* !(_WIN32 && PIC) */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
#endif /* !(_WIN32 && PIC) */
|
|
||||||
|
|
||||||
#ifndef FONTCONFIG_FILE
|
#ifndef FONTCONFIG_FILE
|
||||||
#define FONTCONFIG_FILE "fonts.conf"
|
#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;
|
dir = (FcChar8 *) FONTCONFIG_PATH;
|
||||||
path[i] = malloc (strlen ((char *) dir) + 1);
|
path[i] = malloc (strlen ((char *) dir) + 1);
|
||||||
if (!path[i])
|
if (!path[i])
|
||||||
|
@ -1707,7 +1723,7 @@ FcChar8 *
|
||||||
FcConfigFilename (const FcChar8 *url)
|
FcConfigFilename (const FcChar8 *url)
|
||||||
{
|
{
|
||||||
FcChar8 *file, *dir, **path, **p;
|
FcChar8 *file, *dir, **path, **p;
|
||||||
|
|
||||||
if (!url || !*url)
|
if (!url || !*url)
|
||||||
{
|
{
|
||||||
url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
|
url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
|
||||||
|
|
22
src/fcxml.c
22
src/fcxml.c
|
@ -2058,7 +2058,27 @@ FcEndElement(void *userData, const XML_Char *name)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#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;
|
int rc;
|
||||||
FcStrFree (data);
|
FcStrFree (data);
|
||||||
|
|
Loading…
Reference in New Issue