1 # ----------- freetype.m4 ----------------
4 # * freetype library (-lfreetype)
5 # * freetype headers (freetype2/freetype/freetype.h)
6 # * whether a freetype test program can be compiled
18 AC_DEFUN([RFX_CHECK_FONTCONFIG],
20 OLDCPPFLAGS="${CPPFLAGS}"
23 if test -d /usr/include/fontconfig; then
24 CPPFLAGS="$CPPFLAGS -I/usr/include/fontconfig"
27 AC_CHECK_LIB(fontconfig, FcInit, [HAVE_LIB_FONTCONFIG=1],)
28 AC_CHECK_HEADERS(fontconfig.h,[HAVE_FONTCONFIG_H=1])
30 if test "x${HAVE_LIB_FONTCONFIG}" != "x";then
31 if test "x${HAVE_FONTCONFIG_H}" != "x";then
36 if test "x${HAVE_FONTCONFIG}" = "x1"; then
37 LIBS="$LIBS -lfontconfig"
38 AC_MSG_CHECKING([whether we can compile the fontconfig test program])
40 if (echo $LIBS | grep lfreetype >/dev/null 2>&1); then
41 #move freetype library to the end of libraries, otherwise fontconfig
43 LIBS=`echo $LIBS | sed -e 's/-lfreetype//g' -e 's/$/ -lfreetype/'`
46 cat > conftest.c << EOF
48 #include <fontconfig.h>
52 FcPattern *pattern, *match;
55 char*s1="abc",*s2="ABC";
58 pattern = FcPatternBuild(0, FC_FAMILY, FcTypeString, "", 0);
59 FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
60 FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
62 FcConfig*c = FcConfigCreate();
63 FcConfigParseAndLoad(c, (FcChar8*)"", 1);
64 FcConfigBuildFonts(c);
65 FcConfigSetCurrent(c);
67 FcFontSet * set = FcConfigGetFonts(c, FcSetSystem);
68 FcFontSetDestroy(set);
70 FcConfigSubstitute(0, pattern, FcMatchPattern);
71 FcDefaultSubstitute(pattern);
72 match = FcFontMatch(0, pattern, &result);
73 FcPatternGetString(match, "family", 0, &v) == FcResultMatch;
74 FcPatternGetBool(match, "family", 0, &v) == FcResultMatch;
75 FcPatternPrint(pattern);
76 FcPatternDestroy(pattern);
77 FcPatternDestroy(match);
83 ac_link='$CC $CPPFLAGS $CFLAGS conftest.c $LDFLAGS $LIBS -o conftest${ac_exeext}'
84 if { (eval echo freetype.m4:71: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
86 AC_DEFINE([HAVE_FONTCONFIG], [1], [Define if fontconfig is available])
88 echo "configure: failed program was:" >&5
96 # if the above didn't work out, reset all changes to the compiler variables.
97 if test "x${HAVE_FONTCONFIG}" "!=" "x1"; then