aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-04-13 11:42:04 +0200
committermarha <marha@users.sourceforge.net>2012-04-13 11:42:04 +0200
commitd2d4fd66a0c1fca50d07fce3f383d6a84a57f09a (patch)
treeb50ae20ca22bc564b145906d6c84395285933859 /fontconfig/src
parent120bd371deb2b73a0bae5ce331511e4ea27bcff2 (diff)
parentfffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 (diff)
downloadvcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.tar.gz
vcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.tar.bz2
vcxsrv-d2d4fd66a0c1fca50d07fce3f383d6a84a57f09a.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'fontconfig/src')
-rw-r--r--fontconfig/src/Makefile.am1
-rw-r--r--fontconfig/src/fcint.h18
-rw-r--r--fontconfig/src/fcmatch.c84
-rw-r--r--fontconfig/src/fcstr.c52
-rw-r--r--fontconfig/src/fcxml.c48
5 files changed, 164 insertions, 39 deletions
diff --git a/fontconfig/src/Makefile.am b/fontconfig/src/Makefile.am
index 591fc1613..0bd0e3ded 100644
--- a/fontconfig/src/Makefile.am
+++ b/fontconfig/src/Makefile.am
@@ -71,6 +71,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/src \
$(FREETYPE_CFLAGS) \
+ $(ICONV_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(EXPAT_CFLAGS) \
$(WARN_CFLAGS) \
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index 56f77efef..0dfc23659 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -55,9 +55,17 @@
#endif
#ifdef _WIN32
-#define FC_SEARCH_PATH_SEPARATOR ';'
+# define _WIN32_WINNT 0x0500
+# define WIN32_LEAN_AND_MEAN
+# define STRICT
+# include <windows.h>
+typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
+typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
+extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
+extern pfnSHGetFolderPathA pSHGetFolderPathA;
+# define FC_SEARCH_PATH_SEPARATOR ';'
#else
-#define FC_SEARCH_PATH_SEPARATOR ':'
+# define FC_SEARCH_PATH_SEPARATOR ':'
#endif
#define FC_DBG_MATCH 1
@@ -1009,6 +1017,12 @@ FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
FcPrivate int
FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
+FcPrivate FcBool
+FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
+
+FcPrivate FcBool
+FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
+
FcPrivate const FcChar8 *
FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
diff --git a/fontconfig/src/fcmatch.c b/fontconfig/src/fcmatch.c
index 92e4a6668..655e62cf5 100644
--- a/fontconfig/src/fcmatch.c
+++ b/fontconfig/src/fcmatch.c
@@ -174,6 +174,22 @@ FcCompareSize (FcValue *value1, FcValue *value2)
return v;
}
+static double
+FcCompareFilename (FcValue *v1, FcValue *v2)
+{
+ const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
+ if (FcStrCmp (s1, s2) == 0)
+ return 0.0;
+ else if (FcStrCmpIgnoreCase (s1, s2) == 0)
+ return 1.0;
+ else if (FcStrRegexCmp (s2, s1))
+ return 2.0;
+ else if (FcStrRegexCmpIgnoreCase (s2, s1))
+ return 3.0;
+ else
+ return 4.0;
+}
+
typedef struct _FcMatcher {
FcObject object;
double (*compare) (FcValue *value1, FcValue *value2);
@@ -186,40 +202,42 @@ typedef struct _FcMatcher {
* later values
*/
static const FcMatcher _FcMatchers [] = {
- { FC_FOUNDRY_OBJECT, FcCompareString, 0, 0 },
-#define MATCH_FOUNDRY 0
- { FC_CHARSET_OBJECT, FcCompareCharSet, 1, 1 },
-#define MATCH_CHARSET 1
- { FC_FAMILY_OBJECT, FcCompareFamily, 2, 4 },
-#define MATCH_FAMILY 2
- { FC_LANG_OBJECT, FcCompareLang, 3, 3 },
-#define MATCH_LANG 3
-#define MATCH_LANG_INDEX 3
- { FC_SPACING_OBJECT, FcCompareNumber, 5, 5 },
-#define MATCH_SPACING 4
- { FC_PIXEL_SIZE_OBJECT, FcCompareSize, 6, 6 },
-#define MATCH_PIXEL_SIZE 5
- { FC_STYLE_OBJECT, FcCompareString, 7, 7 },
-#define MATCH_STYLE 6
- { FC_SLANT_OBJECT, FcCompareNumber, 8, 8 },
-#define MATCH_SLANT 7
- { FC_WEIGHT_OBJECT, FcCompareNumber, 9, 9 },
-#define MATCH_WEIGHT 8
- { FC_WIDTH_OBJECT, FcCompareNumber, 10, 10 },
-#define MATCH_WIDTH 9
- { FC_DECORATIVE_OBJECT, FcCompareBool, 11, 11 },
-#define MATCH_DECORATIVE 10
- { FC_ANTIALIAS_OBJECT, FcCompareBool, 12, 12 },
-#define MATCH_ANTIALIAS 11
- { FC_RASTERIZER_OBJECT, FcCompareString, 13, 13 },
-#define MATCH_RASTERIZER 12
- { FC_OUTLINE_OBJECT, FcCompareBool, 14, 14 },
-#define MATCH_OUTLINE 13
- { FC_FONTVERSION_OBJECT, FcCompareNumber, 15, 15 },
-#define MATCH_FONTVERSION 14
+ { FC_FILE_OBJECT, FcCompareFilename, 0, 0 },
+#define MATCH_FILE 0
+ { FC_FOUNDRY_OBJECT, FcCompareString, 1, 1 },
+#define MATCH_FOUNDRY 1
+ { FC_CHARSET_OBJECT, FcCompareCharSet, 2, 2 },
+#define MATCH_CHARSET 2
+ { FC_FAMILY_OBJECT, FcCompareFamily, 3, 5 },
+#define MATCH_FAMILY 3
+ { FC_LANG_OBJECT, FcCompareLang, 4, 4 },
+#define MATCH_LANG 4
+#define MATCH_LANG_INDEX 4
+ { FC_SPACING_OBJECT, FcCompareNumber, 6, 6 },
+#define MATCH_SPACING 5
+ { FC_PIXEL_SIZE_OBJECT, FcCompareSize, 7, 7 },
+#define MATCH_PIXEL_SIZE 6
+ { FC_STYLE_OBJECT, FcCompareString, 8, 8 },
+#define MATCH_STYLE 7
+ { FC_SLANT_OBJECT, FcCompareNumber, 9, 9 },
+#define MATCH_SLANT 8
+ { FC_WEIGHT_OBJECT, FcCompareNumber, 10, 10 },
+#define MATCH_WEIGHT 9
+ { FC_WIDTH_OBJECT, FcCompareNumber, 11, 11 },
+#define MATCH_WIDTH 10
+ { FC_DECORATIVE_OBJECT, FcCompareBool, 12, 12 },
+#define MATCH_DECORATIVE 11
+ { FC_ANTIALIAS_OBJECT, FcCompareBool, 13, 13 },
+#define MATCH_ANTIALIAS 12
+ { FC_RASTERIZER_OBJECT, FcCompareString, 14, 14 },
+#define MATCH_RASTERIZER 13
+ { FC_OUTLINE_OBJECT, FcCompareBool, 15, 15 },
+#define MATCH_OUTLINE 14
+ { FC_FONTVERSION_OBJECT, FcCompareNumber, 16, 16 },
+#define MATCH_FONTVERSION 15
};
-#define NUM_MATCH_VALUES 16
+#define NUM_MATCH_VALUES 17
static const FcMatcher*
FcObjectToMatcher (FcObject object)
@@ -228,6 +246,8 @@ FcObjectToMatcher (FcObject object)
i = -1;
switch (object) {
+ case FC_FILE_OBJECT:
+ i = MATCH_FILE; break;
case FC_FOUNDRY_OBJECT:
i = MATCH_FOUNDRY; break;
case FC_FONTVERSION_OBJECT:
diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c
index b712e5daf..a6f0ba766 100644
--- a/fontconfig/src/fcstr.c
+++ b/fontconfig/src/fcstr.c
@@ -26,6 +26,9 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
#ifdef _WIN32
#include <windows.h>
#endif
@@ -269,6 +272,55 @@ FcStrCmp (const FcChar8 *s1, const FcChar8 *s2)
return (int) c1 - (int) c2;
}
+#ifdef USE_REGEX
+static FcBool
+_FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex, int cflags, int eflags)
+{
+ int ret = -1;
+ regex_t reg;
+
+ if ((ret = regcomp (&reg, (const char *)regex, cflags)) != 0)
+ {
+ if (FcDebug () & FC_DBG_MATCHV)
+ {
+ char buf[512];
+
+ regerror (ret, &reg, buf, 512);
+ printf("Regexp compile error: %s\n", buf);
+ }
+ return FcFalse;
+ }
+ ret = regexec (&reg, (const char *)s, 0, NULL, eflags);
+ if (ret != 0)
+ {
+ if (FcDebug () & FC_DBG_MATCHV)
+ {
+ char buf[512];
+
+ regerror (ret, &reg, buf, 512);
+ printf("Regexp exec error: %s\n", buf);
+ }
+ }
+ regfree (&reg);
+
+ return ret == 0 ? FcTrue : FcFalse;
+}
+#else
+# define _FcStrRegexCmp(_s_, _regex_) (FcFalse)
+#endif
+
+FcBool
+FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex)
+{
+ return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB, 0);
+}
+
+FcBool
+FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex)
+{
+ return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE, 0);
+}
+
/*
* Return a hash value for a string
*/
diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c
index b8701470c..708e131f9 100644
--- a/fontconfig/src/fcxml.c
+++ b/fontconfig/src/fcxml.c
@@ -2323,11 +2323,7 @@ FcEndElement(void *userData, const XML_Char *name)
{
int rc;
data = buffer;
-#if _WIN32_WINNT >= 0x0500
- rc = GetSystemWindowsDirectory (buffer, sizeof (buffer) - 20);
-#else
- rc = GetWindowsDirectory (buffer, sizeof (buffer) - 20);
-#endif
+ rc = pGetSystemWindowsDirectory (buffer, sizeof (buffer) - 20);
if (rc == 0 || rc > sizeof (buffer) - 20)
{
FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed");
@@ -2377,6 +2373,27 @@ FcEndElement(void *userData, const XML_Char *name)
strcat (data, "\\");
strcat (data, "fontconfig\\cache");
}
+ else if (strcmp (data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0)
+ {
+ char szFPath[MAX_PATH + 1];
+ size_t len;
+ FcStrFree (data);
+ if (!(pSHGetFolderPathA && SUCCEEDED(pSHGetFolderPathA(NULL, /* CSIDL_LOCAL_APPDATA */ 28, NULL, 0, szFPath))))
+ {
+ FcConfigMessage (parse, FcSevereError, "SHGetFolderPathA failed");
+ break;
+ }
+ strncat(szFPath, "\\fontconfig\\cache", MAX_PATH - 1 - strlen(szFPath));
+ len = strlen(szFPath) + 1;
+ data = malloc(len);
+ if (!data)
+ {
+ FcConfigMessage (parse, FcSevereError, "out of memory");
+ break;
+ }
+ FcMemAlloc (FC_MEM_STRING, len);
+ strncpy(data, szFPath, len);
+ }
#endif
if (!FcStrUsesHome (data) || FcConfigHome ())
{
@@ -2690,6 +2707,11 @@ bail0:
return ret || !complain;
}
+#ifdef _WIN32
+pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL;
+pfnSHGetFolderPathA pSHGetFolderPathA = NULL;
+#endif
+
FcBool
FcConfigParseAndLoad (FcConfig *config,
const FcChar8 *name,
@@ -2710,6 +2732,22 @@ FcConfigParseAndLoad (FcConfig *config,
void *buf;
#endif
+#ifdef _WIN32
+ if (!pGetSystemWindowsDirectory)
+ {
+ HMODULE hk32 = GetModuleHandleA("kernel32.dll");
+ if (!(pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetProcAddress(hk32, "GetSystemWindowsDirectoryA")))
+ pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetWindowsDirectory;
+ }
+ if (!pSHGetFolderPathA)
+ {
+ HMODULE hSh = LoadLibraryA("shfolder.dll");
+ /* the check is done later, because there is no provided fallback */
+ if (hSh)
+ pSHGetFolderPathA = (pfnSHGetFolderPathA) GetProcAddress(hSh, "SHGetFolderPathA");
+ }
+#endif
+
filename = FcConfigFilename (name);
if (!filename)
goto bail0;