Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
[dcpomatic.git] / src / lib / render_subtitles.cc
index e29d0c75eb957d393404e4ce5c77accd7c7914df..e22c8c44fb19acac05131422d4302ccafb0d2488 100644 (file)
@@ -25,6 +25,7 @@
 #include <cairomm/cairomm.h>
 #include <pangomm.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 using std::list;
 using std::cout;
@@ -32,6 +33,7 @@ using std::string;
 using std::min;
 using std::max;
 using std::pair;
+using std::cerr;
 using std::make_pair;
 using boost::shared_ptr;
 using boost::optional;
@@ -85,7 +87,14 @@ render_subtitle (dcp::SubtitleString const & subtitle, list<shared_ptr<Font> > f
                fc_config = FcConfigCreate ();
        }
 
-       boost::filesystem::path font_file = shared_path () / "LiberationSans-Regular.ttf";
+       boost::filesystem::path font_file;
+       try {
+               font_file = shared_path () / "LiberationSans-Regular.ttf";
+       } catch (boost::filesystem::filesystem_error& e) {
+               /* Hack: try the debian/ubuntu location if getting the shared path failed */
+               font_file = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+       }
+
        BOOST_FOREACH (shared_ptr<Font> i, fonts) {
                if (i->id() == subtitle.font() && i->file ()) {
                        font_file = i->file().get ();