Move the code to find Liberation into util.cc.
authorCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2020 19:58:48 +0000 (21:58 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2020 19:58:48 +0000 (21:58 +0200)
src/lib/reel_writer.cc
src/lib/util.cc
src/lib/util.h

index 770130798010ab0bd9290f0fa80fac8daf112e0d..f5f21f2eac92e5799a901370ecd44c394d654ee2 100644 (file)
@@ -439,24 +439,9 @@ maybe_add_text (
        shared_ptr<T> reel_asset;
 
        if (asset) {
-               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";
-               }
-
                /* Add the font to the subtitle content */
                BOOST_FOREACH (shared_ptr<Font> j, fonts) {
-                       asset->add_font (j->id(), j->file().get_value_or(liberation_normal));
+                       asset->add_font (j->id(), j->file().get_value_or(default_font_file()));
                }
 
                if (dynamic_pointer_cast<dcp::InteropSubtitleAsset> (asset)) {
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;
+}
index 6cfe37bebd0f6034ebe87f40cde23822426e52fb..b4378040abfa5c09cd23464d1a961c641b960c19 100644 (file)
@@ -121,6 +121,7 @@ extern void write_swaroop_chain (boost::shared_ptr<const dcp::CertificateChain>
 #endif
 extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container);
 extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm);
+extern boost::filesystem::path default_font_file ();
 
 template <class T>
 std::list<T>