~ubuntu-branches/ubuntu/lucid/swftools/lucid

« back to all changes in this revision

Viewing changes to m4/freetype.m4

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-04-30 05:22:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430052219-l1n64qofzeq5pej8
Tags: 0.9.0-0ubuntu1
* New upstream release (LP: #369931)
  - patches/01_manpages: edited to match updated version of src/pdf2swf.1 and
    src/wav2swf.1
  - patches/02_faq: edited to match updated version of FAQ
  - patches/04_makefile: edited to delete the patch on lib/Makefile.in and 
    src/Makefile.in (applied upstream)
  - deleted patch 99_configure_for_python2.5_and_2.6 (applied upstream)
  - debian/swftools.doc: deleted installation of TODO and 
    pdf2swf/HOWTO_pdf2swf as they don't exist anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ----------- freetype.m4 ----------------
 
2
#
 
3
# Checks for:
 
4
#    * freetype library (-lfreetype)
 
5
#    * freetype headers (freetype2/freetype/freetype.h)
 
6
#    * whether a freetype test program can be compiled
 
7
 
8
# Environment set:
 
9
#    * HAVE_FREETYPE
 
10
#
 
11
# Defines:
 
12
#    * HAVE_FREETYPE
 
13
#    * USE_FREETYPE
 
14
#
 
15
# Substitutes:
 
16
#
 
17
 
 
18
AC_DEFUN([RFX_CHECK_FREETYPE],
 
19
[
 
20
 
 
21
AC_PATH_PROG([FREETYPE_CONFIG], [freetype-config],, ["$PATH:/usr/local/bin:/sw/bin:/opt/local/bin"])
 
22
 
 
23
OLDCPPFLAGS="${CPPFLAGS}"
 
24
OLDLIBS="${LIBS}"
 
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"
 
31
fi 
 
32
fi
 
33
fi
 
34
 
 
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],)
 
40
fi
 
41
 
 
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])
 
45
fi
 
46
 
 
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
 
50
        HAVE_FREETYPE=1
 
51
    fi
 
52
    if test "x${HAVE_FT2BUILD_H}" '!=' "x";then
 
53
        HAVE_FREETYPE=1
 
54
    fi
 
55
fi
 
56
 
 
57
if test "x${HAVE_FREETYPE}" = "x1"; then 
 
58
    if test "x${FREETYPE_CONFIG}" '!=' "x"; then
 
59
        LIBS="$LIBS "`$FREETYPE_CONFIG --libs`
 
60
    else
 
61
        LIBS="$LIBS -lfreetype"
 
62
    fi
 
63
 
 
64
    if test "x${HAVE_FT2BUILD_H}" = "x1"; then
 
65
        HAVE_FT2BUILD_H_DEFINE='#define HAVE_FT2BUILD_H'
 
66
    fi
 
67
 
 
68
    AC_MSG_CHECKING([whether we can compile the freetype test program])
 
69
 
 
70
    cat > conftest.c << EOF
 
71
$HAVE_FT2BUILD_H_DEFINE
 
72
 
 
73
#ifdef HAVE_FT2BUILD_H
 
74
#include <ft2build.h>
 
75
#include FT_FREETYPE_H
 
76
#include FT_GLYPH_H
 
77
#include FT_SIZES_H
 
78
#include FT_SFNT_NAMES_H
 
79
#include FT_TRUETYPE_IDS_H
 
80
#include FT_OUTLINE_H
 
81
#else
 
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>
 
88
#endif
 
89
 
 
90
int main()
 
91
{
 
92
    FT_Library ftlibrary;
 
93
    FT_Face face;
 
94
    FT_Error error;
 
95
    FT_ULong charcode;
 
96
    FT_UInt gindex;
 
97
    FT_Glyph glyph;
 
98
    FT_BBox bbox;
 
99
    FT_Matrix matrix;
 
100
    FT_UInt i;
 
101
    char* name = 0;
 
102
    char italic, bold;
 
103
   
 
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);
 
115
    }
 
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);
 
120
    FT_Done_Face(face);
 
121
    FT_Done_FreeType(ftlibrary);
 
122
    return 0;
 
123
}
 
124
EOF
 
125
 
 
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
 
128
        AC_MSG_RESULT([yes])
 
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
 
132
    else
 
133
        echo "configure: failed program was:" >&5
 
134
        cat conftest.c >&5
 
135
        HAVE_FREETYPE=0
 
136
        AC_MSG_RESULT([no])
 
137
    fi
 
138
    rm -f conftest*
 
139
fi
 
140
 
 
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
 
144
    LIBS=$OLDLIBS
 
145
fi 
 
146
])
 
147