aboutsummaryrefslogtreecommitdiff
path: root/fontconfig
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig')
-rw-r--r--fontconfig/configure.in139
-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
6 files changed, 275 insertions, 67 deletions
diff --git a/fontconfig/configure.in b/fontconfig/configure.in
index ea44c1422..1af236719 100644
--- a/fontconfig/configure.in
+++ b/fontconfig/configure.in
@@ -123,7 +123,7 @@ dnl ==========================================================================
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
+AC_CHECK_HEADERS([fcntl.h regex.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -133,38 +133,86 @@ AC_TYPE_PID_T
# Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_MMAP
-AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r])
+AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r regcomp regerror regexec regfree])
#
-# Checks for iconv
+# regex
#
-AC_MSG_CHECKING([for a usable iconv])
-ICONV_LIBS=""
-AC_TRY_LINK([#include <iconv.h>],
- [iconv_open ("from", "to");],
- [use_iconv=1],
- [use_iconv=0])
-if test x$use_iconv = x1; then
- AC_MSG_RESULT([libc])
-else
- # try using libiconv
- fontconfig_save_libs="$LIBS"
- LIBS="$LIBS -liconv"
+use_regex=0
+if test "x$ac_cv_func_regcomp" = "xyes" -a "x$ac_cv_func_regerror" = "xyes" -a "x$ac_cv_func_regexec" = "xyes" -a "x$ac_cv_func_regfree"; then
+ use_regex=1
+fi
+AC_DEFINE_UNQUOTED(USE_REGEX,$use_regex,[Use regex.])
- AC_TRY_LINK([#include <iconv.h>],
- [iconv_open ("from", "to");],
- [use_iconv=1],
- [use_iconv=0])
-
- if test x$use_iconv = x1; then
- ICONV_LIBS="-liconv"
- AC_MSG_RESULT([libiconv])
+#
+# Checks for iconv
+#
+AC_ARG_WITH(libiconv,
+ [AC_HELP_STRING([--with-libiconv=DIR],
+ [Use libiconv in DIR])],
+ [libiconv_prefix=$withval],
+ [libiconv_prefix=auto])
+AC_ARG_WITH(libiconv-includes,
+ [AC_HELP_STRING([--with-libiconv-includes=DIR],
+ [Use libiconv includes in DIR])],
+ [libiconv_includes=$withval],
+ [libiconv_includes=auto])
+AC_ARG_WITH(libiconv-lib,
+ [AC_HELP_STRING([--with-libiconv-lib=DIR],
+ [Use libiconv library in DIR])],
+ [libiconv_lib=$withval],
+ [libiconv_lib=auto])
+
+# if none of libiconv,libiconv-includes,libiconv-libs are specified
+if test "$libiconv_prefix" != "auto" -o "$libiconv_includes" != "auto" -o "$libiconv_lib" != "auto"; then
+ if test "$libiconv_includes" != "auto" -a -r ${libiconv_includes}/iconv.h; then
+ libiconv_cflags="-I${libiconv_includes}"
+ elif test "$libiconv_prefix" != "auto" -a -r ${libiconv_prefix}/include/iconv.h; then
+ libiconv_cflags="-I${libiconv_prefix}/include"
+ else
+ libiconv_cflags=""
+ fi
+ if test "$libiconv_lib" != "auto"; then
+ libiconv_lib="-L${libiconv_lib} -liconv"
+ elif test "$libiconv_prefix" != "auto"; then
+ libiconv_lib="-L${libiconv_prefix}/lib -liconv"
+ elif test "x$libiconv_cflags" != "x"; then
+ libiconv_lib="-liconv"
else
- AC_MSG_RESULT([no])
+ libiconv_lib=""
fi
+fi
+
+use_iconv=0
+AC_MSG_CHECKING([for a usable iconv])
+if test "x$libiconv_cflags" != "x" -o "x$libiconv_lib" != "x"; then
+ iconvsaved_CFLAGS="$CFLAGS"
+ iconvsaved_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $libiconv_cflags"
+ LIBS="$LIBS $libiconv_lib"
- LIBS="$fontconfig_save_libs"
+ AC_TRY_LINK([#include <iconv.h>],
+ [iconv_open ("from", "to");],
+ [iconv_type="libiconv"
+ use_iconv=1],
+ [use_iconv=0])
+
+ CFLAGS="$iconvsaved_CFLAGS"
+ LIBS="$iconvsaved_LIBS"
+ ICONV_CFLAGS="$libiconv_cflags"
+ ICONV_LIBS="$libiconv_lib"
+fi
+if test "x$use_iconv" = "x0"; then
+ AC_TRY_LINK([#include <iconv.h>],
+ [iconv_open ("from", "to");],
+ [iconv_type="libc"
+ use_iconv=1],
+ [iconv_type="not found"
+ use_iconv=0])
fi
+
+AC_MSG_RESULT([$iconv_type])
+AC_SUBST(ICONV_CFLAGS)
AC_SUBST(ICONV_LIBS)
AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])
@@ -194,10 +242,45 @@ LIBS="$fontconfig_save_libs"
#
# Check expat configuration
#
+AC_ARG_WITH(expat,
+ [AC_HELP_STRING([--with-expat=DIR],
+ [Use Expat in DIR])],
+ [expat_prefix=$withval],
+ [expat_prefix=auto])
+AC_ARG_WITH(expat-includes,
+ [AC_HELP_STRING([--with-expat-includes=DIR],
+ [Use Expat includes in DIR])],
+ [expat_includes=$withval],
+ [expat_includes=auto])
+AC_ARG_WITH(expat-lib,
+ [AC_HELP_STRING([--with-expat-lib=DIR])],
+ [expat_lib=$withval],
+ [expat_lib=auto])
+
if test "$enable_libxml2" != "yes"; then
- # specify EXPAT_CFLAGS and/or EXPAT_LIBS if you like the old behavior
- # with --with-expat-includes and --with-expat-lib.
- PKG_CHECK_MODULES(EXPAT, expat)
+ use_pkgconfig_for_expat=yes
+ if test "$expat_prefix" = "auto" -a "$expat_includes" = "auto" -a "$expat_lib" = "auto"; then
+ PKG_CHECK_MODULES(EXPAT, expat,,use_pkgconfig_for_expat=no)
+ else
+ use_pkgconfig_for_expat=no
+ fi
+ if test "x$use_pkgconfig_for_expat" = "xno"; then
+ if test "$expat_includes" != "auto" -a -r ${expat_includes}/expat.h; then
+ EXPAT_CFLAGS="-I${expat_includes}"
+ elif test "$expat_prefix" != "auto" -a -r ${expat_prefix}/include/expat.h; then
+ EXPAT_CFLAGS="-I${expat_prefix}/include"
+ else
+ EXPAT_CFLAGS=""
+ fi
+ if test "$expat_lib" != "auto"; then
+ EXPAT_LIBS="-L${expat_lib} -lexpat"
+ elif test "$expat_prefix" != "auto"; then
+ EXPAT_LIBS="-L${expat_prefix}/lib -lexpat"
+ else
+ EXPAT_LIBS="-lexpat"
+ fi
+ fi
+
expatsaved_CPPFLAGS="$CPPFLAGS"
expatsaved_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $EXPAT_CFLAGS"
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;