diff options
author | Sascha Schumann <sas@php.net> | 1999-07-23 15:56:47 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 1999-07-23 15:56:47 +0000 |
commit | 33f30aee64d01e7b3f59ef087b2b250a7eb3a1e5 (patch) | |
tree | 3e9728a0fbde89d2b44f79378744aa1c25f7b48f /ext/gd | |
parent | 2c2e4c463f2fc9e9a5aa492eeafae62713f2fd72 (diff) | |
download | php-git-33f30aee64d01e7b3f59ef087b2b250a7eb3a1e5.tar.gz |
gdttf update
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/config.h.stub | 3 | ||||
-rw-r--r-- | ext/gd/config.m4 | 55 | ||||
-rw-r--r-- | ext/gd/gdttf.c | 20 |
3 files changed, 74 insertions, 4 deletions
diff --git a/ext/gd/config.h.stub b/ext/gd/config.h.stub index 4e619595f7..db06b056cd 100644 --- a/ext/gd/config.h.stub +++ b/ext/gd/config.h.stub @@ -4,3 +4,6 @@ /* Define if you have the gd version 1.3 library (-lgd). */ #define HAVE_LIBGD13 0 +#undef FREETYPE_4BIT_ANTIALIAS_HACK +#undef HAVE_LIBFREETYPE +#undef HAVE_LIBTTF diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 12c6e7bb76..452c151fd3 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -44,11 +44,62 @@ dnl A whole whack of possible places where this might be AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ]) ]) if test "$ac_cv_lib_gd_gdImageLine" = "yes"; then + CHECK_TTF="yes" + AC_ARG_WITH(ttf, + [ --with-ttf[=DIR] Include Freetype support],[ + if test $withval = "no" ; then + CHECK_TTF="" + else + CHECK_TTF="$withval" + fi + ]) + + AC_MSG_CHECKING(whether to include ttf support) + if test -n "$CHECK_TTF" ; then + for i in /usr /usr/local "$CHECK_TTF" ; do + if test -f "$i/include/truetype.h" ; then + FREETYPE_DIR="$i" + fi + if test -f "$i/include/freetype.h" ; then + TTF_DIR="$i" + fi + done + if test -n "$FREETYPE_DIR" ; then + AC_DEFINE(HAVE_LIBFREETYPE) + AC_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE_DIR/lib) + AC_ADD_INCLUDE($FREETYPE_DIR/include) + AC_MSG_RESULT(yes) + else + if test -n "$TTF_DIR" ; then + AC_DEFINE(HAVE_LIBTTF) + AC_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib) + AC_ADD_INCLUDE($TTF_DIR/include) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + else + AC_MSG_RESULT(no) + fi + if test -f /usr/pkg/include/gd/gd.h -a -z "$GD_INCLUDE" ; then GD_INCLUDE="-I/usr/pkg/include/gd" fi - AC_CHECK_LIB(ttf, TT_Open_Face) - AC_CHECK_HEADERS(freetype.h) + + AC_MSG_CHECKING(whether to enable 4bit antialias hack with FreeType2) + AC_ARG_ENABLE(freetype-4bit-antialias-hack, + [ --enable-freetype-4bit-antialias-hack For the crazy with FreeType2.],[ + if test "$enableval" = "yes" ; then + AC_DEFINE(FREETYPE_4BIT_ANTIALIAS_HACK, 1) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + ],[ + AC_MSG_RESULT(no) + ]) + PHP_EXTENSION(gd) EXTRA_LIBS="$EXTRA_LIBS $GD_LIBS" INCLUDES="$INCLUDES $GD_INCLUDE" diff --git a/ext/gd/gdttf.c b/ext/gd/gdttf.c index 33019e030a..f2c1a03a9a 100644 --- a/ext/gd/gdttf.c +++ b/ext/gd/gdttf.c @@ -9,7 +9,7 @@ #else #include "php_config.h" #endif -#ifdef ENABLE_GD_TTF +#if HAVE_LIBTTF|HAVE_LIBFREETYPE #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -17,7 +17,11 @@ #include <gd.h> #include "gdttf.h" #include "gdcache.h" +#if HAVE_LIBFREETYPE +#include <truetype.h> +#else #include <freetype.h> +#endif /* number of fonts cached before least recently used is replaced */ #define FONTCACHESIZE 6 @@ -31,7 +35,11 @@ #define BITMAPCACHESIZE 8 /* number of antialias color lookups cached */ +#if FREETYPE_4BIT_ANTIALIAS_HACK +#define TWEENCOLORCACHESIZE 128 +#else #define TWEENCOLORCACHESIZE 32 +#endif /* ptsize below which anti-aliasing is ineffective */ #define MINANTIALIASPTSIZE 0 @@ -40,7 +48,11 @@ #define RESOLUTION 72 /* Number of colors used for anti-aliasing */ +#if FREETYPE_4BIT_ANTIALIAS_HACK +#define NUMCOLORS 16 +#else #define NUMCOLORS 4 +#endif /* Line separation as a factor of font height. No space between if LINESPACE = 1.00 @@ -379,7 +391,11 @@ fontFetch ( char **error, void *key ) a->cos_a = cos(a->angle); a->engine = b->engine; if ((err = TT_Open_Face(*b->engine, a->fontname, &a->face))) { +#if HAVE_LIBFREETYPE + if (err == 0x008) { /* The FT2 oldapi is missing this code */ +#else if (err == TT_Err_Could_Not_Open_File) { +#endif *error = "Could not find/open font"; } else { @@ -852,7 +868,7 @@ gdttf(gdImage *im, int *brect, int fg, char *fontname, return (char *)NULL; } -#endif /* ENABLE_GD_TTF */ +#endif /* HAVE_LIBTTF|HAVE_LIBFREETYPE */ /* * Local variables: |