fix up unexpected situation with fontconfig in our packages
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 5 May 2012 14:16:13 +0000 (14:16 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 5 May 2012 14:16:13 +0000 (14:16 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12190 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/curvetest.cc
gtk2_ardour/main.cc
tools/linux_packaging/build

index 498ed45eba958cdbef3d62598dfbdb05a827f59d..b3431e3f395ad128b09f973f2b4b63d0024f7b99 100644 (file)
@@ -32,6 +32,11 @@ using namespace PBD;
 int
 curvetest (string filename)
 {
+       // needed to initialize ID objects/counter used
+       // by Curve et al.
+
+       PBD::ID::init ();
+
        ifstream in (filename.c_str());
        stringstream line;
        //Evoral::Parameter param(GainAutomation, -1.0, +1.0, 0.0);
@@ -40,11 +45,6 @@ curvetest (string filename)
        double minx = DBL_MAX;
        double maxx = DBL_MIN;
 
-       // needed to initialize ID objects/counter used
-       // by Curve et al.
-
-       PBD::ID::init ();
-
        while (in) {
                double x, y;
 
index a853d7b61bf3b895d4e7eedfa887143e00374db2..9803ea2f05d624a4cbd5e64445cd84273a1e57be 100644 (file)
@@ -21,6 +21,7 @@
 #include <signal.h>
 #include <cerrno>
 #include <fstream>
+#include <vector>
 
 #include <sigc++/bind.h>
 #include <gtkmm/settings.h>
@@ -289,6 +290,10 @@ fixup_bundle_environment (int, char* [])
 void
 fixup_bundle_environment (int /*argc*/, char* argv[])
 {
+       /* THIS IS FOR LINUX - its just about the only place where its
+        * acceptable to build paths directly using '/'.
+        */
+
        if (!getenv ("ARDOUR_BUNDLED")) {
                return;
        }
@@ -370,32 +375,45 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
        if (g_mkdir_with_parents (userconfigdir.c_str(), 0755) < 0) {
                error << string_compose (_("cannot create user ardour folder %1 (%2)"), userconfigdir, strerror (errno))
                      << endmsg;
-       } else {
-
-               Glib::ustring mpath;
-
-               path = Glib::build_filename (userconfigdir, "pango.rc");
-
-               std::ofstream pangorc (path.c_str());
-               if (!pangorc) {
-                       error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
-               } else {
-                       mpath = Glib::build_filename (userconfigdir, "pango.modules");
-
-                       pangorc << "[Pango]\nModuleFiles=";
-                       pangorc << mpath << endl;
-                       pangorc.close ();
-               }
+               return;
+       } 
 
-               setenv ("PANGO_RC_FILE", path.c_str(), 1);
+       Glib::ustring mpath;
+       
+       path = Glib::build_filename (userconfigdir, "pango.rc");
+       
+       std::ofstream pangorc (path.c_str());
+       if (!pangorc) {
+               error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
+       } else {
+               mpath = Glib::build_filename (userconfigdir, "pango.modules");
+               
+               pangorc << "[Pango]\nModuleFiles=";
+               pangorc << mpath << endl;
+               pangorc.close ();
+       }
+       
+       setenv ("PANGO_RC_FILE", path.c_str(), 1);
 
-               /* similar for GDK pixbuf loaders, but there's no RC file required
-                  to specify where it lives.
-               */
+       /* Tell fontconfig where to find fonts.conf. Use the system version
+          if it exists, otherwise use the stuff we included in t
+       */
 
-               mpath = Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders");
-               setenv ("GDK_PIXBUF_MODULE_FILE", mpath.c_str(), 1);
+       if (Glib::file_test ("/etc/fonts/fonts.conf", Glib::FILE_TEST_EXISTS)) {
+               setenv ("/etc/fonts/fonts.conf", path.c_str(), 1);
+       } else {
+               /* use the one included in the bundle */
+               
+               path = Glib::build_filename (dir_path, "etc/fonts/fonts.conf");
+               setenv ("FONTCONFIG_FILE", path.c_str(), 1);
        }
+       
+       /* similar for GDK pixbuf loaders, but there's no RC file required
+          to specify where it lives.
+       */
+       
+       mpath = Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders");
+       setenv ("GDK_PIXBUF_MODULE_FILE", mpath.c_str(), 1);
 }
 
 #endif
index 6a67af120c961e859719fc05ae126f34638e9df8..f8d1843352c139f3423e2d4ba100c56b2b57c692 100755 (executable)
@@ -280,6 +280,25 @@ else
        echo "Skipping NLS support"
 fi
 
+### Find fontconfig ###
+FCROOT=`pkg-config --libs-only-L fontconfig | sed -e "s/-L//" -e "s/[[:space:]]//g"`
+if [ ! -z "$FCROOT" ]; then
+       echo "Found FCOOT using pkg-config"
+        FCETC=`dirname $FCROOT`/etc
+elif [ -d /usr/lib/gtk-2.0 ]; then
+       FCETC="/etc"
+elif [ -d /usr/local/lib/gtk-2.0 ]; then
+       FCETC="/usr/local/etc"
+else
+       echo ""
+       echo "!!! ERROR !!! - Unable to locate fontconfig directory. Packager will exit"
+       echo ""
+       exit 1
+fi
+
+echo "Copying Fontconfig files to $Etc ..."
+cp -r $FCETC/fonts $Etc
+
 ### Find gtk ###
 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
 if [ ! -z "$GTKROOT" ]; then