changeset 24900:00d42b86d0a5 stable

configure: new option --with-system-freefont to use system fonts (bug #53348) * configure.ac (--with-system-freefont): New command-line option. (SYSTEM_FREEFONT_DIR): New preprocessor macro. (AMCOND_INSTALL_INTERNAL_FONT_FILES): New automake conditional. * etc/module.mk (octfonts_DATA): Include $(fallback_FONT_FILES) in the list only when AMCOND_INSTALL_INTERNAL_FONT_FILES is true. * ft-text-renderer.cc (ft_manager::do_get_font): Use SYSTEM_FREEFONT_DIR if it is defined.
author Mike Miller <mtmiller@octave.org>
date Fri, 16 Mar 2018 16:59:40 -0700
parents 1a46d174a483
children a73dedb0d9b5 8862b95d64ec
files configure.ac etc/module.mk libinterp/corefcn/ft-text-renderer.cc
diffstat 3 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Mar 16 15:28:34 2018 -0700
+++ b/configure.ac	Fri Mar 16 16:59:40 2018 -0700
@@ -276,6 +276,34 @@
 AC_DEFINE_UNQUOTED([SHELL_PATH], ["$SHELL_PATH"],
   [Define this to be the path to the shell command interpreter.])
 
+### Use the system-wide installation of GNU FreeFont if the user requests it.
+### By default, Octave includes its own copy of the FreeSans font, which it
+### installs in its own directory for use as a fallback default font.  If this
+### configuration option is used, then do not install our own copy of the fonts
+### and assume they can be found in the provided system directory.
+SYSTEM_FREEFONT_DIR=
+AC_ARG_WITH([system-freefont],
+  [AS_HELP_STRING([--with-system-freefont=DIR],
+    [use FreeSans fonts in DIR (default: install and use internal copy)])])
+case $with_system_freefont in
+  no | "")
+    SYSTEM_FREEFONT_DIR=
+    ;;
+  yes)
+    AC_MSG_ERROR([directory argument required for --with-system-freefont])
+    ;;
+  *)
+    SYSTEM_FREEFONT_DIR=$with_system_freefont
+    ;;
+esac
+if test -n "$SYSTEM_FREEFONT_DIR"; then
+  AC_MSG_NOTICE([configuring Octave to use system fonts in $SYSTEM_FREEFONT_DIR])
+  AC_DEFINE_UNQUOTED([SYSTEM_FREEFONT_DIR], ["$SYSTEM_FREEFONT_DIR"],
+    [Define this to be the system directory containing the GNU FreeFont fonts.])
+fi
+AM_CONDITIONAL([AMCOND_INSTALL_INTERNAL_FONT_FILES],
+  [test -z "$SYSTEM_FREEFONT_DIR"])
+
 ### Determine which C++ compiler to use (we expect to find g++).
 
 AC_PROG_CXX
--- a/etc/module.mk	Fri Mar 16 15:28:34 2018 -0700
+++ b/etc/module.mk	Fri Mar 16 16:59:40 2018 -0700
@@ -27,8 +27,10 @@
   %reldir%/fonts/FreeSansBoldOblique.otf \
   %reldir%/fonts/FreeSansOblique.otf
 
+if AMCOND_INSTALL_INTERNAL_FONT_FILES
 octfonts_DATA += \
   $(fallback_FONT_FILES)
+endif
 
 %canon_reldir%_EXTRA_DIST += \
   $(fallback_FONT_FILES)
--- a/libinterp/corefcn/ft-text-renderer.cc	Fri Mar 16 15:28:34 2018 -0700
+++ b/libinterp/corefcn/ft-text-renderer.cc	Fri Mar 16 16:59:40 2018 -0700
@@ -213,7 +213,11 @@
           fonts_dir = sys::env::getenv ("OCTAVE_FONTS_DIR");
 
           if (fonts_dir.empty ())
+#if defined (SYSTEM_FREEFONT_DIR)
+            fonts_dir = SYSTEM_FREEFONT_DIR;
+#else
             fonts_dir = config::oct_fonts_dir ();
+#endif
         }