Commits

Anonymous committed 480330b

- sync to 2.0.22

  • Participants
  • Parent commits 06e39b1
  • Tags GD_2_0_22

Comments (0)

Files changed (18)

File src/Makefile.in

 LDFLAGS = @LDFLAGS@
 LIBICONV = @LIBICONV@
 LIBOBJS = @LIBOBJS@
+LIBPNG12_CONFIG = @LIBPNG12_CONFIG@
 LIBPNG_CONFIG = @LIBPNG_CONFIG@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@

File src/circletexttest.c

 #include <stdio.h>
 #include <gd.h>
 
+/* 2.0.22: oops, we need config.h */
+#include "config.h"
+
 int
 main (int argc, char *argv[])
 {
+	/* 2.0.22: can't depend on PNG either  */
+#ifndef HAVE_LIBPNG
+	fprintf(stderr, "Requires PNG support, gd was compiled without it\n");
+	exit(0);
+#else
 	FILE *in = 0;
 	FILE *out;
 	gdImagePtr im;
 	gdImagePng(im, out);
 	fclose(out);
 	gdImageDestroy(im);
+#endif /* HAVE_LIBPNG */
 	return 0;
 }
 

File src/configure

 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.57 for GD 2.0.21.
+# Generated by GNU Autoconf 2.57 for GD 2.0.22.
 #
 # Report bugs to <gd@boutell.com>.
 #
 # Identity of this package.
 PACKAGE_NAME='GD'
 PACKAGE_TARNAME='gd'
-PACKAGE_VERSION='2.0.21'
-PACKAGE_STRING='GD 2.0.21'
+PACKAGE_VERSION='2.0.22'
+PACKAGE_STRING='GD 2.0.22'
 PACKAGE_BUGREPORT='gd@boutell.com'
 
 ac_unique_file="gd.c"
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBICONV LTLIBICONV LIBPNG_CONFIG FREETYPE_CONFIG PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBICONV LTLIBICONV LIBPNG12_CONFIG LIBPNG_CONFIG FREETYPE_CONFIG PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures GD 2.0.21 to adapt to many kinds of systems.
+\`configure' configures GD 2.0.22 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of GD 2.0.21:";;
+     short | recursive ) echo "Configuration of GD 2.0.22:";;
    esac
   cat <<\_ACEOF
 
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-GD configure 2.0.21
+GD configure 2.0.22
 generated by GNU Autoconf 2.57
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by GD $as_me 2.0.21, which was
+It was created by GD $as_me 2.0.22, which was
 generated by GNU Autoconf 2.57.  Invocation command line was
 
   $ $0 $@
 
 GDLIB_MAJOR=2
 GDLIB_MINOR=0
-GDLIB_REVISION=21
+GDLIB_REVISION=22
 GDLIBNAME=gd
 
 
 
 # Define the identity of the package.
  PACKAGE=gd
- VERSION=2.0.21
+ VERSION=2.0.22
 
 
 cat >>confdefs.h <<_ACEOF
   withval=yes
 fi;
 
+# libpng12.so is a nightmare. We have to test separately for
+# libpng12-config and libpng-config. If we find libpng12-config,
+# we don't look for the other, which will just be a symlink to it,
+# confusing autoconf into thinking the library itself will be named -lpng,
+# which it won't be. Awful. This code will suffice unless the libpng
+# authors decide to do this AGAIN. Which I really hope they won't. TBB
+
 if test "$withval" != no; then
+  # Extract the first word of "libpng12-config", so it can be a program name with args.
+set dummy libpng12-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_LIBPNG12_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $LIBPNG12_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LIBPNG12_CONFIG="$LIBPNG12_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_LIBPNG12_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  ;;
+esac
+fi
+LIBPNG12_CONFIG=$ac_cv_path_LIBPNG12_CONFIG
+
+if test -n "$LIBPNG12_CONFIG"; then
+  echo "$as_me:$LINENO: result: $LIBPNG12_CONFIG" >&5
+echo "${ECHO_T}$LIBPNG12_CONFIG" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
   # Extract the first word of "libpng-config", so it can be a program name with args.
 set dummy libpng-config; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-  if test -n "$LIBPNG_CONFIG"; then
+  if test -n "$LIBPNG12_CONFIG"; then
+    libpng_CPPFLAGS=`libpng12-config --cflags`
+    # should be --ldopts, but it's currently broken
+    libpng_LDFLAGS=`libpng12-config --ldflags`
+    libpng_LDFLAGS=`echo " $libpng_LDFLAGS" | sed 's/ -l[^ ][^ ]*//g'`
+  elif test -n "$LIBPNG_CONFIG"; then
     libpng_CPPFLAGS=`libpng-config --cflags`
     # should be --ldopts, but it's currently broken
     libpng_LDFLAGS=`libpng-config --ldflags`
     libpng_LDFLAGS="-L$withval/lib"
   fi
 
-  _cppflags="$CPPFLAGS"
-  _ldflags="$LDFLAGS"
-  CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS"
-  LDFLAGS="$LDFLAGS $libpng_LDFLAGS"
-
 
 for ac_header in png.h
 do
 done
 
 
+  if test -n "$LIBPNG12_CONFIG"; then
+    echo "$as_me:$LINENO: checking for png_create_read_struct in -lpng12" >&5
+echo $ECHO_N "checking for png_create_read_struct in -lpng12... $ECHO_C" >&6
+if test "${ac_cv_lib_png12_png_create_read_struct+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng12  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char png_create_read_struct ();
+int
+main ()
+{
+png_create_read_struct ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_png12_png_create_read_struct=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_png12_png_create_read_struct=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_png12_png_create_read_struct" >&5
+echo "${ECHO_T}$ac_cv_lib_png12_png_create_read_struct" >&6
+if test $ac_cv_lib_png12_png_create_read_struct = yes; then
+  LIBS="-lpng12 $LIBS"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LIBPNG 1
+_ACEOF
+
+else
+  LDFLAGS="$_ldflags"
+       { echo "$as_me:$LINENO: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&5
+echo "$as_me: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&2;}
+fi
+
+  elif test -n "$LIBPNG_CONFIG"; then
+
+echo "$as_me:$LINENO: checking for png_create_read_struct in -lpng" >&5
+echo $ECHO_N "checking for png_create_read_struct in -lpng... $ECHO_C" >&6
+if test "${ac_cv_lib_png_png_create_read_struct+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char png_create_read_struct ();
+int
+main ()
+{
+png_create_read_struct ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_png_png_create_read_struct=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_png_png_create_read_struct=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_create_read_struct" >&5
+echo "${ECHO_T}$ac_cv_lib_png_png_create_read_struct" >&6
+if test $ac_cv_lib_png_png_create_read_struct = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPNG 1
+_ACEOF
+
+  LIBS="-lpng $LIBS"
+
+else
+  LDFLAGS="$_ldflags"
+       { echo "$as_me:$LINENO: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&5
+echo "$as_me: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&2;}
+fi
+
+  else
 
 echo "$as_me:$LINENO: checking for png_create_read_struct in -lpng" >&5
 echo $ECHO_N "checking for png_create_read_struct in -lpng... $ECHO_C" >&6
 
 else
   LDFLAGS="$_ldflags"
-     { echo "$as_me:$LINENO: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&5
+       { echo "$as_me:$LINENO: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&5
 echo "$as_me: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&2;}
 fi
 
+  fi
 else
   ac_cv_lib_png_png_create_read_struct=no
   { echo "$as_me:$LINENO: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&5
 echo "$as_me: WARNING: libpng is required - see http://www.libpng.org/pub/png/" >&2;}
 fi
 
+#TBB: png12's png_create_read_struct is just as good
+
+if test "$ac_cv_lib_png12_png_create_read_struct" == yes; then
+  ac_cv_lib_png_png_create_read_struct=yes
+fi
+
 
 # Check whether --with-freetype or --without-freetype was given.
 if test "${with_freetype+set}" = set; then
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by GD $as_me 2.0.21, which was
+This file was extended by GD $as_me 2.0.22, which was
 generated by GNU Autoconf 2.57.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-GD config.status 2.0.21
+GD config.status 2.0.22
 configured by $0, generated by GNU Autoconf 2.57,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
 s,@LIBTOOL@,$LIBTOOL,;t t
 s,@LIBICONV@,$LIBICONV,;t t
 s,@LTLIBICONV@,$LTLIBICONV,;t t
+s,@LIBPNG12_CONFIG@,$LIBPNG12_CONFIG,;t t
 s,@LIBPNG_CONFIG@,$LIBPNG_CONFIG,;t t
 s,@FREETYPE_CONFIG@,$FREETYPE_CONFIG,;t t
 s,@PTHREAD_CC@,$PTHREAD_CC,;t t

File src/configure.ac

 AC_PREREQ(2.54)
 
 #HEY! Change BOTH the vesion number and the GDLIB_REVISION setting!
-AC_INIT([GD], [2.0.21], [gd@boutell.com])
+AC_INIT([GD], [2.0.22], [gd@boutell.com])
 AC_CONFIG_SRCDIR([gd.c])
 AC_CONFIG_AUX_DIR(config)
 
 GDLIB_MAJOR=2
 GDLIB_MINOR=0
-GDLIB_REVISION=21
+GDLIB_REVISION=22
 GDLIBNAME=gd
 
 AC_SUBST(GDLIB_MAJOR)
 [  --with-png=DIR          where to find the png library],,
   withval=yes)
 
+# libpng12.so is a nightmare. We have to test separately for
+# libpng12-config and libpng-config. If we find libpng12-config,
+# we don't look for the other, which will just be a symlink to it,
+# confusing autoconf into thinking the library itself will be named -lpng,
+# which it won't be. Awful. This code will suffice unless the libpng
+# authors decide to do this AGAIN. Which I really hope they won't. TBB
+
 if test "$withval" != no; then
+  AC_PATH_PROG([LIBPNG12_CONFIG], [libpng12-config])
   AC_PATH_PROG([LIBPNG_CONFIG], [libpng-config])
-  if test -n "$LIBPNG_CONFIG"; then
+  if test -n "$LIBPNG12_CONFIG"; then
+    libpng_CPPFLAGS=`libpng12-config --cflags`
+    # should be --ldopts, but it's currently broken
+    libpng_LDFLAGS=`libpng12-config --ldflags`
+    libpng_LDFLAGS=`echo " $libpng_LDFLAGS" | sed 's/ -l[[^ ]][[^ ]]*//g'`
+  elif test -n "$LIBPNG_CONFIG"; then
     libpng_CPPFLAGS=`libpng-config --cflags`
     # should be --ldopts, but it's currently broken
     libpng_LDFLAGS=`libpng-config --ldflags`
     libpng_LDFLAGS="-L$withval/lib"
   fi
 
-  _cppflags="$CPPFLAGS"
-  _ldflags="$LDFLAGS"
-  CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS"
-  LDFLAGS="$LDFLAGS $libpng_LDFLAGS"
-
   AC_CHECK_HEADERS(png.h,,
     [AC_CHECK_HEADERS(libpng/png.h,
        [CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS/libpng"],
        [CPPFLAGS="$_cppflags"])])
 
-  AC_CHECK_LIB(png,png_create_read_struct,,
-    [LDFLAGS="$_ldflags"  
-     AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])])
+  if test -n "$LIBPNG12_CONFIG"; then
+    AC_CHECK_LIB(png12,png_create_read_struct,
+      [LIBS="-lpng12 $LIBS"
+       AC_DEFINE(HAVE_LIBPNG, 1, [ Define if you have the png library. ])],
+      [LDFLAGS="$_ldflags"  
+       AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])])
+  elif test -n "$LIBPNG_CONFIG"; then
+    AC_CHECK_LIB(png,png_create_read_struct,,
+      [LDFLAGS="$_ldflags"  
+       AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])])
+  else
+    AC_CHECK_LIB(png,png_create_read_struct,,
+      [LDFLAGS="$_ldflags"  
+       AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])])
+  fi
 else
   ac_cv_lib_png_png_create_read_struct=no
   AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])
 fi
 
+#TBB: png12's png_create_read_struct is just as good 
+
+if test "$ac_cv_lib_png12_png_create_read_struct" == yes; then
+  ac_cv_lib_png_png_create_read_struct=yes
+fi 
+
 dnl FreeType configure tests snarfed from libwmf ..
 AC_ARG_WITH(freetype,dnl
 [  --with-freetype=DIR     where to find the freetype 2.x library],
+/* TODO: make sure you didn't break resampling */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
       bd = (im->blue[i] - b);
       /* gd 2.02: whoops, was - b (thanks to David Marwood) */
       /* gd 2.16: was blue rather than alpha! Geez! Thanks to 
-		Artur Jakub Jerzak */
+         Artur Jakub Jerzak */
       ad = (im->alpha[i] - a);
       dist = rd * rd + gd * gd + bd * bd + ad * ad;
       if (first || (dist < mindist))
   int Bx_Cx = im->AAL_x2 - px;
   int By_Cy = im->AAL_y2 - py;
   /* 2.0.13: bounds check! AA_opacity is just as capable of
-    overflowing as the main pixel array. Arne Jorgensen. 
-    2.0.14: typo fixed. 2.0.15: moved down below declarations
-    to satisfy non-C++ compilers. */
+     overflowing as the main pixel array. Arne Jorgensen. 
+     2.0.14: typo fixed. 2.0.15: moved down below declarations
+     to satisfy non-C++ compilers. */
   if (!gdImageBoundsSafeMacro (im, px, py))
-  {
-    return;
-  }
+    {
+      return;
+    }
   /* Get the squares of the lengths of the segemnts AC and BC. */
   LAC_2 = (Ax_Cx * Ax_Cx) + (Ay_Cy * Ay_Cy);
   LBC_2 = (Bx_Cx * Bx_Cx) + (By_Cy * By_Cy);
   /* Fixed by Mao Morimoto 2.0.16 */
   for (i = 0; (i < srcW); i++)
     {
-      stx[i] = dstW * (i+1) / srcW - dstW * i / srcW ;
+      stx[i] = dstW * (i + 1) / srcW - dstW * i / srcW;
     }
   for (i = 0; (i < srcH); i++)
     {
-      sty[i] = dstH * (i+1) / srcH - dstH * i / srcH ;
+      sty[i] = dstH * (i + 1) / srcH - dstH * i / srcH;
     }
   for (i = 0; (i < gdMaxColors); i++)
     {
 		      mapTo = gdImageGetTrueColorPixel (src, x, y);
 		      if (gdImageGetTransparent (src) == tmp)
 			{
-                          /* 2.0.21, TK: not tox++ */
-                          tox += stx[x - srcX];
+			  /* 2.0.21, TK: not tox++ */
+			  tox += stx[x - srcX];
 			  continue;
 			}
 		    }
 		      /* Added 7/24/95: support transparent copies */
 		      if (gdImageGetTransparent (src) == mapTo)
 			{
-                          /* 2.0.21, TK: not tox++ */
-                          tox += stx[x - srcX];
+			  /* 2.0.21, TK: not tox++ */
+			  tox += stx[x - srcX];
 			  continue;
 			}
 		    }
 		      int dstW, int dstH, int srcW, int srcH)
 {
   int x, y;
+  double sy1, sy2, sx1, sx2;
   if (!dst->trueColor)
     {
       gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
     }
   for (y = dstY; (y < dstY + dstH); y++)
     {
+      sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH;
+      sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH /
+	(double) dstH;
       for (x = dstX; (x < dstX + dstW); x++)
 	{
-	  float sy1, sy2, sx1, sx2;
-	  float sx, sy;
-	  float spixels = 0;
-	  float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
-	  sy1 = ((float) y - (float) dstY) * (float) srcH / (float) dstH;
-	  sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH /
-	    (float) dstH;
+	  double sx, sy;
+	  double spixels = 0;
+	  double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
+	  sx1 = ((double) x - (double) dstX) * (double) srcW / dstW;
+	  sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW;
 	  sy = sy1;
 	  do
 	    {
-	      float yportion;
+	      double yportion;
 	      if (floor2 (sy) == floor2 (sy1))
 		{
 		  yportion = 1.0 - (sy - floor2 (sy));
 		{
 		  yportion = 1.0;
 		}
-	      sx1 = ((float) x - (float) dstX) * (float) srcW / dstW;
-	      sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW / dstW;
 	      sx = sx1;
 	      do
 		{
-		  float xportion;
-		  float pcontribution;
+		  double xportion;
+		  double pcontribution;
 		  int p;
 		  if (floor2 (sx) == floor2 (sx1))
 		    {
 	}
     }
   /* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */
-  if (miny < 0) {
-    miny = 0;
-  }
-  if (maxy >= gdImageSY(im)) {
-    maxy = gdImageSY(im) - 1;
-  } 
+  if (miny < 0)
+    {
+      miny = 0;
+    }
+  if (maxy >= gdImageSY (im))
+    {
+      maxy = gdImageSY (im) - 1;
+    }
   /* Fix in 1.3: count a vertex only once */
   for (y = miny; (y <= maxy); y++)
     {
 void
 gdImageSetClip (gdImagePtr im, int x1, int y1, int x2, int y2)
 {
-  if (x1 < 0) {
-    x1 = 0;
-  }
-  if (x1 >= im->sx) {
-    x1 = im->sx - 1;
-  }
-  if (x2 < 0) {
-    x2 = 0;
-  }
-  if (x2 >= im->sx) {
-    x2 = im->sx - 1;
-  }
-  if (y1 < 0) {
-    y1 = 0;
-  }
-  if (y1 >= im->sy) {
-    y1 = im->sy - 1;
-  }
-  if (y2 < 0) {
-    y2 = 0;
-  }
-  if (y2 >= im->sy) {
-    y2 = im->sy - 1;
-  }
+  if (x1 < 0)
+    {
+      x1 = 0;
+    }
+  if (x1 >= im->sx)
+    {
+      x1 = im->sx - 1;
+    }
+  if (x2 < 0)
+    {
+      x2 = 0;
+    }
+  if (x2 >= im->sx)
+    {
+      x2 = im->sx - 1;
+    }
+  if (y1 < 0)
+    {
+      y1 = 0;
+    }
+  if (y1 >= im->sy)
+    {
+      y1 = im->sy - 1;
+    }
+  if (y2 < 0)
+    {
+      y2 = 0;
+    }
+  if (y2 >= im->sy)
+    {
+      y2 = im->sy - 1;
+    }
   im->cx1 = x1;
   im->cy1 = y1;
   im->cx2 = x2;
   *x2P = im->cx2;
   *y2P = im->cy2;
 }
-
-

File src/gd_jpeg.c

 
 void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile);
 
+static int CMYKToRGB(int c, int m, int y, int k, int inverted);
+
 /* 
  * Create a gd-format image from the JPEG-format INFILE.  Returns the
  * image, or NULL upon error.
   JSAMPROW rowptr[1];
   int i, j, retval;
   JDIMENSION nrows;
-
+  int channels = 3;
+  int inverted = 0;
 #ifdef JPEG_DEBUG
   printf ("gd-jpeg: gd JPEG version %s\n", GD_JPEG_VERSION);
   printf ("gd-jpeg: JPEG library version %d, %d-bit sample values\n",
 
   jpeg_gdIOCtx_src (&cinfo, infile);
 
+  /* 2.0.22: save the APP14 marker to check for Adobe Photoshop CMYK
+    files with inverted components. */
+  jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 256);
+
   retval = jpeg_read_header (&cinfo, TRUE);
   if (retval != JPEG_HEADER_OK)
     fprintf (stderr, "gd-jpeg: warning: jpeg_read_header returns"
 	     " %d, expected %d\n", retval, JPEG_HEADER_OK);
-
+  
   if (cinfo.image_height > INT_MAX)
     fprintf (stderr, "gd-jpeg: warning: JPEG image height (%u) is"
 	     " greater than INT_MAX (%d) (and thus greater than"
       fprintf (stderr, "gd-jpeg error: cannot allocate gdImage" " struct\n");
       goto error;
     }
-
-  /*
-   * Force the image into RGB colorspace, but don't 
-   * reduce the number of colors anymore (GD 2.0) 
-   */
-  cinfo.out_color_space = JCS_RGB;
+  /* 2.0.22: very basic support for reading CMYK colorspace files. Nice for
+    thumbnails but there's no support for fussy adjustment of the
+    assumed properties of inks and paper. */
+  if ((cinfo.jpeg_color_space == JCS_CMYK) ||
+    (cinfo.jpeg_color_space == JCS_YCCK))
+  {
+    cinfo.out_color_space = JCS_CMYK;
+  } else {
+    cinfo.out_color_space = JCS_RGB;
+  }
 
   if (jpeg_start_decompress (&cinfo) != TRUE)
     fprintf (stderr, "gd-jpeg: warning: jpeg_start_decompress"
 #if 0
   gdImageInterlace (im, cinfo.progressive_mode != 0);
 #endif
-  if (cinfo.output_components != 3)
+  if (cinfo.out_color_space == JCS_RGB) 
+  {
+    if (cinfo.output_components != 3)
     {
       fprintf (stderr, "gd-jpeg: error: JPEG color quantization"
 	       " request resulted in output_components == %d"
-	       " (expected 3)\n", cinfo.output_components);
+	       " (expected 3 for RGB)\n", cinfo.output_components);
       goto error;
     }
-
+    channels = 3;
+  } else if (cinfo.out_color_space == JCS_CMYK) {
+    jpeg_saved_marker_ptr marker;
+    if (cinfo.output_components != 4)
+    {
+      fprintf (stderr, "gd-jpeg: error: JPEG color quantization"
+	       " request resulted in output_components == %d"
+	       " (expected 4 for CMYK)\n", cinfo.output_components);
+      goto error;
+    }
+    channels = 4;
+    marker = cinfo.marker_list;
+    while (marker) {
+      if ((marker->marker == (JPEG_APP0 + 14)) &&
+        (marker->data_length >= 12) && (!strncmp((const char *) marker->data,
+          "Adobe", 5)))
+      {
+        inverted = 1;
+        break;
+      }
+      marker = marker->next;
+    }
+  } else {
+    fprintf (stderr, "gd-jpeg: error: unexpected colorspace\n");
+    goto error;
+  }
 #if BITS_IN_JSAMPLE == 12
   fprintf (stderr, "gd-jpeg: error: jpeg library was compiled for 12-bit\n"
 	   "precision. This is mostly useless, because JPEGs on the web are\n"
   goto error;
 #endif /* BITS_IN_JSAMPLE == 12 */
 
-  row = gdCalloc (cinfo.output_width * 3, sizeof (JSAMPLE));
+  row = gdCalloc (cinfo.output_width * channels, sizeof (JSAMPLE));
   if (row == 0)
     {
       fprintf (stderr, "gd-jpeg: error: unable to allocate row for"
       goto error;
     }
   rowptr[0] = row;
-
-  for (i = 0; i < cinfo.output_height; i++)
-    {
-      register JSAMPROW currow = row;
-      register int *tpix = im->tpixels[i];
-      nrows = jpeg_read_scanlines (&cinfo, rowptr, 1);
-      if (nrows != 1)
-	{
-	  fprintf (stderr, "gd-jpeg: error: jpeg_read_scanlines"
-		   " returns %u, expected 1\n", nrows);
-	  goto error;
-	}
-      for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++)
-	{
-	  *tpix = gdTrueColor (currow[0], currow[1], currow[2]);
-	}
-    }
-
+  if (cinfo.out_color_space == JCS_CMYK) {
+    for (i = 0; i < cinfo.output_height; i++)
+      {
+        register JSAMPROW currow = row;
+        register int *tpix = im->tpixels[i];
+        nrows = jpeg_read_scanlines (&cinfo, rowptr, 1);
+        if (nrows != 1)
+  	{
+  	  fprintf (stderr, "gd-jpeg: error: jpeg_read_scanlines"
+  		   " returns %u, expected 1\n", nrows);
+  	  goto error;
+  	}
+        for (j = 0; j < cinfo.output_width; j++, currow += 4, tpix++)
+  	{
+  	  *tpix = CMYKToRGB (currow[0], currow[1], currow[2], currow[3], inverted);
+  	}
+      }
+  } else {
+    for (i = 0; i < cinfo.output_height; i++)
+      {
+        register JSAMPROW currow = row;
+        register int *tpix = im->tpixels[i];
+        nrows = jpeg_read_scanlines (&cinfo, rowptr, 1);
+        if (nrows != 1)
+  	{
+  	  fprintf (stderr, "gd-jpeg: error: jpeg_read_scanlines"
+  		   " returns %u, expected 1\n", nrows);
+  	  goto error;
+  	}
+        for (j = 0; j < cinfo.output_width; j++, currow += 3, tpix++)
+  	{
+  	  *tpix = gdTrueColor (currow[0], currow[1], currow[2]);
+  	}
+      }
+  } 
   if (jpeg_finish_decompress (&cinfo) != TRUE)
     fprintf (stderr, "gd-jpeg: warning: jpeg_finish_decompress"
 	     " reports suspended data source\n");
   return 0;
 }
 
+/* A very basic conversion approach, TBB */
+ 
+static int CMYKToRGB(int c, int m, int y, int k, int inverted)
+{
+  if (inverted) {
+    c = 255 - c;
+    m = 255 - m;
+    y = 255 - y;
+    k = 255 - k;
+  }
+  return gdTrueColor((255 - c) * (255 - k) / 255,
+     (255 - m) * (255 - k) / 255, 
+     (255 - y) * (255 - k) / 255);
+#if 0
+  if (inverted) {
+    c = 255 - c;
+    m = 255 - m;
+    y = 255 - y;
+    k = 255 - k;
+  }
+  c = c * (255 - k) / 255 + k;
+  if (c > 255) {
+    c = 255;
+  }
+  if (c < 0) {
+    c = 0;
+  } 
+  m = m * (255 - k) / 255 + k;
+  if (m > 255) {
+    m = 255;
+  }
+  if (m < 0) {
+    m = 0;
+  } 
+  y = y * (255 - k) / 255 + k;
+  if (y > 255) {
+    y = 255;
+  }
+  if (y < 0) {
+    y = 0;
+  } 
+  c = 255 - c;
+  m = 255 - m;
+  y = 255 - y;
+  return gdTrueColor(c, m, y);
+#endif
+}
+
 /*
 
  * gdIOCtx JPEG data sources and sinks, T. Boutell

File src/gddemo.c

 #include <math.h>
 #include <stdlib.h>
 #include "gd.h"
-#include "gdfontg.h"
+#include "gdfontt.h"
 #include "gdfonts.h"
+#include "gdfontmb.h"
+#include "gdfontl.h"
+#include "gdfontg.h"
 
 int
 main (void)
   gdPoint points[3];
   int i;
 
+  /* gd fonts for font test */
+  gdFontPtr fonts[5];
+  int y;
+
   /* Create output image, in true color. */
   im_out = gdImageCreateTrueColor (256 + 384, 384);
   /* 2.0.2: first color allocated would automatically be background in a 
       gdImageLine (im_out, 0, 255, 255, 0, gdStyledBrushed);
     }
   /* Text (non-truetype; see gdtestft for a freetype demo) */
-  gdImageString (im_out, gdFontGiant, 32, 32, (unsigned char *) "hi", red);
-  gdImageStringUp (im_out, gdFontSmall, 64, 64, (unsigned char *) "hi", red);
+  fonts[0] = gdFontGetTiny();
+  fonts[1] = gdFontGetSmall();
+  fonts[2] = gdFontGetMediumBold();
+  fonts[3] = gdFontGetLarge();
+  fonts[4] = gdFontGetGiant();
+  y = 0;
+  for (i = 0; (i <= 4); i++) {
+    gdImageString (im_out, fonts[i], 32, 32 + y, (unsigned char *) "hi", red);
+    y += fonts[i]->h;
+  }
+  y = 0;
+  for (i = 0; (i <= 4); i++) {
+    gdImageStringUp (im_out, fonts[i], 64 + y, 64, 
+    (unsigned char *) "hi", red);
+    y += fonts[i]->h;
+  }
   /* Random antialiased lines; coordinates all over the image, 
     but the output will respect a small clipping rectangle */
   gdImageSetClip(im_out, 0, gdImageSY(im_out) - 100,

File src/gdfontg.c

 
 BGD_EXPORT_DATA_IMPL gdFontPtr gdFontGiant = &gdFontGiantRep;
 
+gdFontPtr gdFontGetGiant(void)
+{
+	return gdFontGiant;
+}
+
 /* This file has not been truncated. */

File src/gdfontg.h

 #include "gd.h"
 
    BGD_EXPORT gdFontPtr gdFontGiant;
+   BGD_EXPORT gdFontPtr gdFontGetGiant(void);
 
 #ifdef __cplusplus
 }

File src/gdfontl.c

 
 BGD_EXPORT_DATA_IMPL gdFontPtr gdFontLarge = &gdFontLargeRep;
 
+gdFontPtr gdFontGetLarge(void)
+{
+	return gdFontLarge;
+}
+
 /* This file has not been truncated. */

File src/gdfontl.h

 #include "gd.h"
 
    BGD_EXPORT gdFontPtr gdFontLarge;
+   BGD_EXPORT gdFontPtr gdFontGetLarge(void);
 
 #ifdef __cplusplus
 }

File src/gdfontmb.c

 
 BGD_EXPORT_DATA_IMPL gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep;
 
+gdFontPtr gdFontGetMediumBold(void)
+{
+	return gdFontMediumBold;
+}
+
 /* This file has not been truncated. */

File src/gdfontmb.h

 #include "gd.h"
 
    BGD_EXPORT  gdFontPtr gdFontMediumBold;
+   BGD_EXPORT  gdFontPtr gdFontGetMediumBold(void);
 
 #ifdef __cplusplus
 }

File src/gdfonts.c

 
 BGD_EXPORT_DATA_IMPL gdFontPtr gdFontSmall = &gdFontSmallRep;
 
+gdFontPtr gdFontGetSmall(void)
+{
+	return gdFontSmall;
+}
+
 /* This file has not been truncated. */

File src/gdfonts.h

 #include "gd.h"
 
    BGD_EXPORT gdFontPtr gdFontSmall;
+   BGD_EXPORT gdFontPtr gdFontGetSmall(void);
 
 #ifdef __cplusplus
 }

File src/gdfontt.c

 
 BGD_EXPORT_DATA_IMPL gdFontPtr gdFontTiny = &gdFontTinyRep;
 
+gdFontPtr gdFontGetTiny(void) 
+{
+	return gdFontTiny;
+}
+
 /* This file has not been truncated. */

File src/gdfontt.h

 #include "gd.h"
 
    BGD_EXPORT  gdFontPtr gdFontTiny;
+   BGD_EXPORT  gdFontPtr gdFontGetTiny(void);
 
 #ifdef __cplusplus
 }

File src/index.html

 <!-- REMEMBER TO EDIT index.html.source -->
 <head>
-<TITLE>gd 2.0.21</TITLE>
+<TITLE>gd 2.0.22</TITLE>
 </head>
 <body bgcolor="#FFFFFF">
 <!-- BANNER HERE -->
-<H2>gd 2.0.21</H2>
+<H2>gd 2.0.22</H2>
 <H3>A graphics library for fast image creation</H3>
 <H3>Follow this link to the
 <A HREF="http://www.boutell.com/gd/">latest version
 new installation overwrites the old.
 <p>
 <strong>ABOUT GD AND GIF:</strong>
-gd 2.0.21 creates PNG, JPEG and WBMP images, not GIF images. This is a 
+gd 2.0.22 creates PNG, JPEG and WBMP images, not GIF images. This is a 
 good thing.  PNG is a more compact format, and full compression is
 available.  JPEG works best with photographic images, and is still
 more compatible with the major Web browsers than even PNG is. WBMP is
 modern image formats such as PNG and JPEG as soon as possible.
 
 <p>
-When building from soruce, gd 2.0.21 <strong>requires</strong> that the 
+When building from soruce, gd 2.0.22 <strong>requires</strong> that the 
 following libraries also be installed, in order to produce the related 
 image formats. The win32 binary release (bgd) already contains the
 appropriate libraries.
 <H3>Table of Contents</H3>
 <UL>
 <LI><A HREF="#notice">Credits and license terms</A>
-<LI><A HREF="#whatsnew2.0.21">What's new in version "XYZ" of GD?</A>
+<LI><A HREF="#whatsnew2.0.22">What's new in version "XYZ" of GD?</A>
 <LI><A HREF="#whatis">What is gd?</A>
 <LI><A HREF="#gdother">What if I want to use another programming language?</A>
 <LI><A HREF="#required">What else do I need to use gd?</A>
 <A NAME="gdother"><H3>What if I want to use another programming
 language?</h3></A>
 Not all of these tools are necessarily up to date and fully compatible
-with 2.0.21.
+with 2.0.22.
 <h4>PHP</h4>
 A variant of gd 2.x is included in PHP 4.3.0. It is also possible
-to patch PHP 4.2.3 for use with gd 2.0.21; see the
+to patch PHP 4.2.3 for use with gd 2.0.22; see the
 <a href="http://www.boutell.com/gd/">gd home page</a> for a link to
 that information. It would be a Good Idea to merge all of the things
 that are better in mainstream gd and all of the things that are
 <a href=http://www.graphviz.org/pub/>Gdtclft</a>
 dynamically loaded extension package.
 <h4>Pascal</h4>
-Pascal enthusiasts should look into Michael Bradbury's
-<a href="http://www.elj.com/dev/free-pascal/gdfp/">gdfp</a> package.
+Pascal enthusiasts should look into the
+<a href="http://www.freepascal.org/">freepascal</a> project, a
+free Pascal compiler that includes gd support.
 <h4>REXX</h4>
 A 
 <a href="http://www.lightlink.com/hessling/RexxGd/index.html">gd interface 
 <li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
 </ul>
 <P>
+<A NAME="whatsnew2.0.22"><H3>What's new in version 2.0.22?</H3></A>
+<P>
+<ul>
+<li>Win32 DLL users: working with pointers exported by DLLs is 
+difficult and causes unexpected results. gd 2.0.22 exports new
+functions for retrieving the basic gd fonts:
+<a href="#gdFontGetTiny">gdFontGetTiny()</a>,
+<a href="#gdFontGetSmall">gdFontGetSmall()</a>,
+<a href="#gdFontGetMediumBold">gdFontGetMediumBold()</a>,
+<a href="#gdFontGetLarge">gdFontGetLarge()</a>, and
+<a href="#gdFontGetHuge">gdFontGetHuge()</a>. You may safely assign the
+return values from these functions to a local <code>gdFontPtr</code>.
+Direct use of <code>gdFontLarge</code>, etc. is strongly deprecated
+for users of <code>bgd.dll</code>; use these new functions instead.
+<li>Basic support for loading CMYK-colorspace JPEG images. They are
+of course converted to RGB which is a lossy process, however the
+results do look quite good and are certainly fine for thumbnails and
+web previews of DTP work.
+<li>"make" no longer fails on <code>circletexttest</code> if 
+PNG support is missing. 
+<li>Small performance improvements to gdImageCopyResampled; larger
+improvements are forthcoming.
+</ul>
+<P>
 <A NAME="whatsnew2.0.21"><H3>What's new in version 2.0.21?</H3></A>
 <P>
 <ul>
 offscreen scanlines during polygon rasterization.
 <li>Optimized PNG saving by Phong Tran. Speeds up saves a 
 little bit. 
+<li>Bug in gdImageCopyResized fixed by Mao Morimoto.
 </ul>
 <P>
 <A NAME="whatsnew2.0.15"><H3>What's new in version 2.0.15?</H3></A>
 </ul>
 <h4>Source Code:</h4>
 <ul>
-<li><a href="http://www.boutell.com/gd/http/gd-2.0.21.tar.gz">Gzipped Tar File (Unix)</a>
-<li><a href="http://www.boutell.com/gd/http/gd-2.0.21.zip">.ZIP File of SOURCE CODE (Windows)</a>
+<li><a href="http://www.boutell.com/gd/http/gd-2.0.22.tar.gz">Gzipped Tar File (Unix)</a>
+<li><a href="http://www.boutell.com/gd/http/gd-2.0.22.zip">.ZIP File of SOURCE CODE (Windows)</a>
 </ul>
 <P>
 <A NAME="buildgd"><H3>How do I build gd?</H3></A>
 consult with an experienced user of your system. Sorry, we cannot
 answer questions about basic Internet skills.
 <p>
-Unpacking the archive will produce a directory called "gd-2.0.21".
+Unpacking the archive will produce a directory called "gd-2.0.22".
 <p>
 <h4>For Unix</h4>
-<code>cd</code> to the 2.0.21 directory and type:
+<code>cd</code> to the 2.0.22 directory and type:
 <p>
 <code>./configure</code>
 <P>
 </DL>
 <H3><A NAME="fonts">Fonts and text-handling functions</A></H3>
 <DL>
+<DT><A NAME="gdFontGetSmall">
+gdFontPtr gdFontGetSmall(void)</a>
+<STRONG>(FUNCTION)</STRONG>
+<DD>
+Returns a font pointer for the "small" gd font. Your code must
+include the header file <code>gdfonts.h</code> before
+calling this function. Under Windows, due to the nature of DLLs, 
+the use of this function is strongly recommended rather than attempting
+to use the <code>gdFontSmall</code> pointer directly. (You may
+safely assign the result to a local <code>gdFontPtr</code> variable
+in your own code.)
+<p>
+See <a href="#gdImageString">gdImageString</a> for more information
+and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
+freetype-based alternative that supports truetype fonts.
+<DT><A NAME="gdFontGetLarge">
+gdFontPtr gdFontGetLarge(void)</a>
+<STRONG>(FUNCTION)</STRONG>
+<DD>
+Returns a font pointer for the "large" gd font. Your code must
+include the header file <code>gdfontl.h</code> before
+calling this function. Under Windows, due to the nature of DLLs, 
+the use of this function is strongly recommended rather than attempting
+to use the <code>gdFontLarge</code> pointer directly. (You may
+safely assign the result to a local <code>gdFontPtr</code> variable
+in your own code.)
+<p>
+See <a href="#gdImageString">gdImageString</a> for more information
+and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
+freetype-based alternative that supports truetype fonts.
+<DT><A NAME="gdFontGetMediumBold">
+gdFontPtr gdFontGetMediumBold(void)</a>
+<STRONG>(FUNCTION)</STRONG>
+<DD>
+Returns a font pointer for the "medium bold" gd font. Your code must
+include the header file <code>gdfontmb.h</code> before
+calling this function. Under Windows, due to the nature of DLLs, 
+the use of this function is strongly recommended rather than attempting
+to use the <code>gdFontMediumBold</code> pointer directly. (You may
+safely assign the result to a local <code>gdFontPtr</code> variable
+in your own code.)
+<p>
+See <a href="#gdImageString">gdImageString</a> for more information
+and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
+freetype-based alternative that supports truetype fonts.
+<DT><A NAME="gdFontGetGiant">
+gdFontPtr gdFontGetGiant(void)</a>
+<STRONG>(FUNCTION)</STRONG>
+<DD>
+Returns a font pointer for the "giant" gd font. Your code must
+include the header file <code>gdfontg.h</code> before
+calling this function. Under Windows, due to the nature of DLLs, 
+the use of this function is strongly recommended rather than attempting
+to use the <code>gdFontGiant</code> pointer directly. (You may
+safely assign the result to a local <code>gdFontPtr</code> variable
+in your own code.)
+<p>
+See <a href="#gdImageString">gdImageString</a> for more information
+and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
+freetype-based alternative that supports truetype fonts.
+<DT><A NAME="gdFontGetTiny">
+gdFontPtr gdFontGetTiny(void)</a>
+<STRONG>(FUNCTION)</STRONG>
+<DD>
+Returns a font pointer for the "tiny" gd font. Your code must
+include the header file <code>gdfontt.h</code> before
+calling this function. Under Windows, due to the nature of DLLs, 
+the use of this function is strongly recommended rather than attempting
+to use the <code>gdFontTiny</code> pointer directly. (You may
+safely assign the result to a local <code>gdFontPtr</code> variable
+in your own code.)
+<p>
+See <a href="#gdImageString">gdImageString</a> for more information
+and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
+freetype-based alternative that supports truetype fonts.
 <DT><A NAME="gdImageChar">
 void gdImageChar(gdImagePtr im, gdFontPtr font, int x, int y,
 	int c, int color)</A>
 solution.)
 The second argument is a pointer to a font definition structure; five fonts are
 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
-gdFontLarge, and gdFontGiant. You must
-include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
+gdFontLarge, and gdFontGiant. 
+<p>
+You must include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
 "gdfontl.h" and "gdfontg.h" respectively
 and (if you are not using a library-based approach) link with the
 corresponding .c files to use the provided fonts.
+<p>
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
+<p>
 The character specified by the fifth
 argument is drawn from left to right in the specified
 color. (See <A HREF="#gdImageCharUp">gdImageCharUp</A> for a way
 /* Allocate the color white (red, green and blue all maximum). */
 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	
 /* Draw a character. */
-gdImageChar(im, gdFontLarge, 0, 0, 'Q', white);
+gdImageChar(im, gdFontGetLarge(), 0, 0, 'Q', white);
 /* ... Do something with the image, such as saving it to a file... */
 /* Destroy it */
 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
 "gdfontl.h" and "gdfontg.h" respectively
 and (if you are not using a library-based approach) link with the
-corresponding .c files to use the provided fonts. The character specified by
+corresponding .c files to use the provided fonts. 
+<p>
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
+<p>
+The character specified by
 the fifth argument is drawn
 from bottom to top, rotated at a 90-degree angle,  in the specified
 color.  (See <A HREF="#gdImageChar">gdImageChar</A> for a way
 /* Allocate the color white (red, green and blue all maximum). */
 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	
 /* Draw a character upwards so it rests against the top of the image. */
-gdImageCharUp(im, gdFontLarge,
-	0, gdFontLarge->h, 'Q', white);
+gdImageCharUp(im, gdFontGetLarge(),
+	0, gdFontGetLarge()->h, 'Q', white);
 /* ... Do something with the image, such as saving it to a file... */
 /* Destroy it */
 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
 "gdfontl.h" and "gdfontg.h" respectively
 and (if you are not using a library-based approach) link with the
 corresponding .c files to use the provided fonts.
+<p>
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
 The null-terminated C string specified
 by the fifth argument is drawn from left to right in the specified
 color.  (See <A HREF="#gdImageStringUp">gdImageStringUp</A> for a way
 /* Allocate the color white (red, green and blue all maximum). */
 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	
 /* Draw a centered string. */
-gdImageString(im, gdFontLarge,
-	im->sx / 2 - (strlen(s) * gdFontLarge->w / 2),
-	im->sy / 2 - gdFontLarge->h / 2,
+gdImageString(im, gdFontGetLarge(),
+	im->sx / 2 - (strlen(s) * gdFontGetLarge()->w / 2),
+	im->sy / 2 - gdFontGetLarge()->h / 2,
 	s, white);
 /* ... Do something with the image, such as saving it to a file... */
 /* Destroy it */
 unsigned short *s, int color)</A>
 <STRONG>(FUNCTION)</STRONG>
 <DD>
-gdImageString is used to draw multiple 16-bit characters on the image.
+gdImageString16 is used to draw multiple 16-bit characters on the image.
 (To draw single characters, use <A HREF="#gdImageChar">
-gdImageChar</A>.) The second argument is a
-pointer to a font definition structure; five fonts are
-provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
-gdFontLarge, and gdFontGiant. You must
-include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
-"gdfontl.h" and "gdfontg.h" respectively
-and (if you are not using a library-based approach) link with the
-corresponding .c files to use the provided fonts.
+gdImageChar16</A>.) The second argument is a
+pointer to a font definition structure; no 16-bit fonts are
+provided with gd as standard equipment and there does not seem to be
+much momentum to create them although the bdftogd script can do so. The 
+preferred solution is <a href="#gdImageStringFT">gdImageStringFT</a>, which
+uses freetype to provide truetype font support. 
+<p>
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
 The null-terminated string of characters represented as 16-bit unsigned
 short integers specified by the fifth argument is drawn from left to right
 in the specified
 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
 "gdfontl.h" and "gdfontg.h" respectively
 and (if you are not using a library-based approach) link with the
-corresponding .c files to use the provided fonts.The null-terminated C string specified
+corresponding .c files to use the provided fonts.
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
+
+The null-terminated C string specified
 by the fifth argument is drawn from bottom to top (rotated
 90 degrees) in the specified color.  (See
 <A HREF="#gdImageString">gdImageString</A> for a way
 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);	
 /* Draw a centered string going upwards. Axes are reversed,
 	and Y axis is decreasing as the string is drawn. */
-gdImageStringUp(im, gdFontLarge,
-	im->w / 2 - gdFontLarge->h / 2,
-	im->h / 2 + (strlen(s) * gdFontLarge->w / 2),
+gdImageStringUp(im, gdFontGetLarge(),
+	im->w / 2 - gdFontGetLarge()->h / 2,
+	im->h / 2 + (strlen(s) * gdFontGetLarge()->w / 2),
 	s, white);
 /* ... Do something with the image, such as saving it to a file... */
 /* Destroy it */
 "gdfontl.h" and "gdfontg.h" respectively
 and (if you are not using a library-based approach) link with the
 corresponding .c files to use the provided fonts.
+<blockquote>
+<b>Windows DLL users:</b> although you can use
+these DLL-exported pointers directly, you cannot easily assign them to other 
+pointers. This will cause hard-to-debug problems. To avoid such troubles, you 
+should call the functions gdFontGetTiny(), gdFontGetSmall(), 
+gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to 
+obtain pointers to the fonts under Windows.
+</blockquote>
 The null-terminated string of characters represented as 16-bit unsigned
 short integers specified by the fifth argument is drawn from bottom to top
 in the specified color.
 <A HREF="#gdBrushed">gdBrushed</A> |
 <A HREF="#gdDashSize">gdDashSize</A> |
 <A HREF="#gdFont">gdFont</A> |
+<A HREF="#gdFontGetHuge">gdFontGetHuge</A> |
+<A HREF="#gdFontGetLarge">gdFontGetLarge</A> |
+<A HREF="#gdFontGetMediumBold">gdFontGetMediumBold</A> |
+<A HREF="#gdFontGetSmall">gdFontGetSmall</A> |
+<A HREF="#gdFontGetTiny">gdFontGetTiny</A> |
 <A HREF="#gdFontCacheSetup">gdFontCacheSetup</A> |
 <A HREF="#gdFontCacheShutdown">gdFontCacheShutdown</A> |
 <A HREF="#gdFontPtr">gdFontPtr</A> |