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_FREETYPE,
20 AC_CHECK_PROGS(FREETYPE_CONFIG, freetype-config,)
21 OLDCPPFLAGS="${CPPFLAGS}"
23 if test "x${FREETYPE_CONFIG}" '!=' "x"; then
24 CPPFLAGS="$CPPFLAGS "`freetype-config --cflags`
25 else if test -d /usr/include/freetype2; then
26 CPPFLAGS="$CPPFLAGS -I/usr/include/freetype2"
27 else if test -d /usr/local/include/freetype2; then
28 CPPFLAGS="$CPPFLAGS -I/usr/local/include/freetype2"
33 if test "x${FREETYPE_CONFIG}" '=' "x";then
34 # if we didn't find the freetype-config program, we won't
35 # know where the libs are expected to be. So just blindly
36 # try to link against them.
37 AC_CHECK_LIB(freetype, FT_Init_FreeType,HAVE_LIB_FREETYPE=1,)
40 AC_CHECK_HEADERS(ft2build.h,HAVE_FT2BUILD_H=1)
41 if test "x${HAVE_FT2BUILD_H}" '=' "x";then
42 AC_CHECK_HEADERS(freetype/freetype.h,HAVE_FREETYPE_FREETYPE_H=1)
45 if test "x${HAVE_LIB_FREETYPE}" '!=' "x" -o \
46 "x${FREETYPE_CONFIG}" '!=' "x";then
47 if test "x${HAVE_FREETYPE_FREETYPE_H}" '!=' "x";then
50 if test "x${HAVE_FT2BUILD_H}" '!=' "x";then
55 if test "x${HAVE_FREETYPE}" = "x1"; then
56 if test "x${FREETYPE_CONFIG}" '!=' "x"; then
57 LIBS="$LIBS "`freetype-config --libs`
59 LIBS="$LIBS -lfreetype"
62 if test "x${HAVE_FT2BUILD_H}" = "x1"; then
63 HAVE_FT2BUILD_H_DEFINE='#define HAVE_FT2BUILD_H'
66 AC_MSG_CHECKING([whether we can compile the freetype test program])
68 cat > conftest.c << EOF
69 $HAVE_FT2BUILD_H_DEFINE
71 #ifdef HAVE_FT2BUILD_H
73 #include FT_FREETYPE_H
76 #include FT_SFNT_NAMES_H
77 #include FT_TRUETYPE_IDS_H
80 #include <freetype/freetype.h>
81 #include <freetype/ftglyph.h>
82 #include <freetype/ftsizes.h>
83 #include <freetype/ftsnames.h>
84 #include <freetype/ttnameid.h>
85 #include <freetype/ftoutln.h>
102 FT_Init_FreeType(&ftlibrary);
103 FT_New_Face(ftlibrary, "filename", 0, &face);
104 i = face->num_glyphs - 1;
105 italic = face->style_flags&FT_STYLE_FLAG_ITALIC;
106 bold = face->style_flags&FT_STYLE_FLAG_BOLD;
107 FT_Get_Postscript_Name(face);
108 FT_Get_Char_Index(face, 33);
109 FT_Get_First_Char(face, &i);
110 FT_Get_Next_Char(face, 33, &i);
111 if(FT_HAS_GLYPH_NAMES(face)) {
112 FT_Get_Glyph_Name(face, 33, name, 127);
114 FT_Load_Glyph(face, 33, FT_LOAD_NO_BITMAP|FT_LOAD_NO_SCALE);
115 FT_Get_Glyph(face->glyph, &glyph);
116 FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
117 FT_Done_Glyph(glyph);
119 FT_Done_FreeType(ftlibrary);
124 ac_link='$CC $CPPFLAGS $CFLAGS conftest.c $LDFLAGS $LIBS -o conftest${ac_exeext}'
125 if { (eval echo freetype.m4:71: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
127 AC_DEFINE_UNQUOTED(HAVE_FREETYPE, 1)
128 AC_DEFINE_UNQUOTED(USE_FREETYPE, 1) # for ttf2tp1
130 echo "configure: failed program was:" >&5
138 # if the above didn't work out, reset all changes to the compiler variables.
139 if test "x${HAVE_FREETYPE}" '!=' "x1"; then
140 CPPFLAGS=$OLDCPPFLAGS