Commit 5637641407b17ffc654896351cc36d61cccde740

sammy 2008-05-12T14:10:05

* Add an m4 check to look for a font file on the system.

diff --git a/configure.ac b/configure.ac
index 7ebb818..fc89836 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ AC_PATH_XTRA
 
 FTGL_CHECK_GL
 FTGL_CHECK_GLUT
+FTGL_CHECK_FONT
 
 PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [CPPUNIT="no"])
 AC_MSG_RESULT($CPPUNIT)
diff --git a/m4/font.m4 b/m4/font.m4
new file mode 100644
index 0000000..663ecc2
--- /dev/null
+++ b/m4/font.m4
@@ -0,0 +1,36 @@
+dnl FTGL_CHECK_FONT()
+dnl Look for a TrueType font somewhere on the system. If no font is found,
+dnl no big deal, example programs will just require one in the command line.
+dnl This finds DejaVu, Bitstream and Microsoft fonts on Debian, Ubuntu, Gentoo,
+dnl Fedora, Mandriva, Slackware and OS X systems.
+dnl Also, we prefer serif fonts because they have elegant curves that render
+dnl well in OpenGL.
+dnl
+AC_DEFUN([FTGL_CHECK_FONT],
+[dnl
+AC_MSG_CHECKING(for a TrueType font on the system)
+FONT_FILE=no
+for font in \
+  DejaVuSerif.ttf VeraSe.ttf DejaVuSans.ttf Vera.ttf \
+  times.ttf Times.ttf arial.ttf Arial.ttf; do
+    for dir in \
+      /usr/share/fonts \
+      /usr/share/fonts/truetype \
+      /usr/share/fonts/truetype/ttf-dejavu \
+      /usr/share/fonts/truetype/ttf-bitstream-vera \
+      /usr/share/fonts/TTF \
+      /usr/share/fonts/TTF/dejavu \
+      /usr/share/fonts/dejavu \
+      /usr/share/fonts/ttf-dejavu \
+      /usr/share/fonts/ttf-bitstream-vera \
+      /usr/X11R6/lib/X11/fonts \
+      /usr/X11R6/lib/X11/fonts/TTF; do
+        if test -f "$dir/$font"; then FONT_FILE="$dir/$font"; break; fi
+    done
+    if test "$FONT_FILE" != no; then
+        AC_DEFINE_UNQUOTED(FONT_FILE, "$FONT_FILE", [Define to the path to a TrueType font])
+        break
+    fi
+done
+AC_MSG_RESULT($FONT_FILE)
+])