diff options
author | marha <marha@users.sourceforge.net> | 2012-04-13 11:34:03 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-13 11:34:03 +0200 |
commit | fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 (patch) | |
tree | 6fbefab2db2acc7f2d5b066b06649ea88e0d6ab3 /fontconfig/src | |
parent | 5f8448ef6b85a9ff72c5af4cec99183c8bb60dc6 (diff) | |
download | vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.gz vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.bz2 vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.zip |
fontconfig xserver xkeyboard-config mesa git update 13 Apr 2012
Diffstat (limited to 'fontconfig/src')
-rw-r--r-- | fontconfig/src/Makefile.am | 1 | ||||
-rw-r--r-- | fontconfig/src/fccache.c | 3 | ||||
-rw-r--r-- | fontconfig/src/fcint.h | 18 | ||||
-rw-r--r-- | fontconfig/src/fcmatch.c | 84 | ||||
-rw-r--r-- | fontconfig/src/fcstr.c | 52 | ||||
-rw-r--r-- | fontconfig/src/fcxml.c | 52 |
6 files changed, 164 insertions, 46 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/fccache.c b/fontconfig/src/fccache.c index d8102d7b4..db7561f9e 100644 --- a/fontconfig/src/fccache.c +++ b/fontconfig/src/fccache.c @@ -36,9 +36,6 @@ #if defined(HAVE_MMAP) || defined(__CYGWIN__) # include <unistd.h> # include <sys/mman.h> -#elif defined(_WIN32) -# define _WIN32_WINNT 0x0500 -# include <windows.h> #endif #ifndef O_BINARY 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 (®, (const char *)regex, cflags)) != 0) + { + if (FcDebug () & FC_DBG_MATCHV) + { + char buf[512]; + + regerror (ret, ®, buf, 512); + printf("Regexp compile error: %s\n", buf); + } + return FcFalse; + } + ret = regexec (®, (const char *)s, 0, NULL, eflags); + if (ret != 0) + { + if (FcDebug () & FC_DBG_MATCHV) + { + char buf[512]; + + regerror (ret, ®, buf, 512); + printf("Regexp exec error: %s\n", buf); + } + } + regfree (®); + + 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 79dfc0b8d..708e131f9 100644 --- a/fontconfig/src/fcxml.c +++ b/fontconfig/src/fcxml.c @@ -53,10 +53,6 @@ #endif /* ENABLE_LIBXML2 */ #ifdef _WIN32 -#define _WIN32_WINNT 0x0500 -#define STRICT -#include <windows.h> -#undef STRICT #include <mbstring.h> #endif @@ -2327,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"); @@ -2381,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 ()) { @@ -2694,6 +2707,11 @@ bail0: return ret || !complain; } +#ifdef _WIN32 +pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL; +pfnSHGetFolderPathA pSHGetFolderPathA = NULL; +#endif + FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *name, @@ -2714,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; |