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],
21 AC_PATH_PROG([FREETYPE_CONFIG], [freetype-config],, ["$PATH:/usr/local/bin:/sw/bin:/opt/local/bin"])
23 OLDCPPFLAGS="${CPPFLAGS}"
25 if test "x${FREETYPE_CONFIG}" '!=' "x"; then
26 CPPFLAGS="$CPPFLAGS "`$FREETYPE_CONFIG --cflags`
27 else if test -d /usr/include/freetype2; then
28 CPPFLAGS="$CPPFLAGS -I/usr/include/freetype2"
29 else if test -d /usr/local/include/freetype2; then
30 CPPFLAGS="$CPPFLAGS -I/usr/local/include/freetype2"
35 if test "x${FREETYPE_CONFIG}" '=' "x";then
36 # if we didn't find the freetype-config program, we won't
37 # know where the libs are expected to be. So just blindly
38 # try to link against them.
39 AC_CHECK_LIB([freetype], [FT_Init_FreeType],[HAVE_LIB_FREETYPE=1],)
42 AC_CHECK_HEADERS([ft2build.h],[HAVE_FT2BUILD_H=1])
43 if test "x${HAVE_FT2BUILD_H}" '=' "x";then
44 AC_CHECK_HEADERS([freetype/freetype.h],[HAVE_FREETYPE_FREETYPE_H=1])
47 if test "x${HAVE_LIB_FREETYPE}" '!=' "x" -o \
48 "x${FREETYPE_CONFIG}" '!=' "x";then
49 if test "x${HAVE_FREETYPE_FREETYPE_H}" '!=' "x";then
52 if test "x${HAVE_FT2BUILD_H}" '!=' "x";then
57 if test "x${HAVE_FREETYPE}" = "x1"; then
58 if test "x${FREETYPE_CONFIG}" '!=' "x"; then
59 LIBS="$LIBS "`$FREETYPE_CONFIG --libs`
61 LIBS="$LIBS -lfreetype"
64 if test "x${HAVE_FT2BUILD_H}" = "x1"; then
65 HAVE_FT2BUILD_H_DEFINE='#define HAVE_FT2BUILD_H'
68 AC_MSG_CHECKING([whether we can compile the freetype test program])
70 cat > conftest.c << EOF
71 $HAVE_FT2BUILD_H_DEFINE
73 #ifdef HAVE_FT2BUILD_H
75 #include FT_FREETYPE_H
78 #include FT_SFNT_NAMES_H
79 #include FT_TRUETYPE_IDS_H
82 #include <freetype/freetype.h>
83 #include <freetype/ftglyph.h>
84 #include <freetype/ftsizes.h>
85 #include <freetype/ftsnames.h>
86 #include <freetype/ttnameid.h>
87 #include <freetype/ftoutln.h>
104 FT_Init_FreeType(&ftlibrary);
105 FT_New_Face(ftlibrary, "filename", 0, &face);
106 i = face->num_glyphs - 1;
107 italic = face->style_flags&FT_STYLE_FLAG_ITALIC;
108 bold = face->style_flags&FT_STYLE_FLAG_BOLD;
109 FT_Get_Postscript_Name(face);
110 FT_Get_Char_Index(face, 33);
111 FT_Get_First_Char(face, &i);
112 FT_Get_Next_Char(face, 33, &i);
113 if(FT_HAS_GLYPH_NAMES(face)) {
114 FT_Get_Glyph_Name(face, 33, name, 127);
116 FT_Load_Glyph(face, 33, FT_LOAD_NO_BITMAP|FT_LOAD_NO_SCALE);
117 FT_Get_Glyph(face->glyph, &glyph);
118 FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
119 FT_Done_Glyph(glyph);
121 FT_Done_FreeType(ftlibrary);
126 ac_link='$CC $CPPFLAGS $CFLAGS conftest.c $LDFLAGS $LIBS -o conftest${ac_exeext}'
127 if { (eval echo freetype.m4:71: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
129 AC_DEFINE([HAVE_FREETYPE], [1], [have/use freetype library])
130 AC_DEFINE([HAVE_FREETYPE_FREETYPE_H], [1], [Define if freetype headers are available])
131 AC_DEFINE([USE_FREETYPE], [1], [Define if freetype is available]) # for ttf2tp1
133 echo "configure: failed program was:" >&5
141 # if the above didn't work out, reset all changes to the compiler variables.
142 if test "x${HAVE_FREETYPE}" '!=' "x1"; then
143 CPPFLAGS=$OLDCPPFLAGS