Move the code to find Liberation into util.cc.
[dcpomatic.git] / src / lib / util.cc
index 7ba9242fae5d795b6a9a1a0d7cf77cdd103bf531..84138f4d94aa7194f2f1f9ce82edad04fa970174 100644 (file)
@@ -1253,3 +1253,24 @@ decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm)
        }
 }
 
+
+boost::filesystem::path
+default_font_file ()
+{
+       boost::filesystem::path liberation_normal;
+       try {
+               liberation_normal = shared_path() / "LiberationSans-Regular.ttf";
+               if (!boost::filesystem::exists (liberation_normal)) {
+                       /* Hack for unit tests */
+                       liberation_normal = shared_path() / "fonts" / "LiberationSans-Regular.ttf";
+               }
+       } catch (boost::filesystem::filesystem_error& e) {
+
+       }
+
+       if (!boost::filesystem::exists(liberation_normal)) {
+               liberation_normal = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+       }
+
+       return liberation_normal;
+}