Make it OK to re-examine content with subtitles.
[dcpomatic.git] / src / lib / string_text_file_content.cc
index 3750b0a5026a70db90b54dfdfe67ea2465fe6a62..95a2821748a344e1a6ea986658f1d409df3f1446 100644 (file)
 */
 
 
-#include "string_text_file_content.h"
-#include "util.h"
-#include "string_text_file.h"
 #include "film.h"
 #include "font.h"
+#include "font_config.h"
+#include "string_text_file.h"
+#include "string_text_file_content.h"
 #include "text_content.h"
+#include "util.h"
 #include <dcp/raw_convert.h>
+#include <fontconfig/fontconfig.h>
 #include <libxml++/libxml++.h>
 #include <iostream>
 
@@ -38,6 +40,7 @@ using std::list;
 using std::make_shared;
 using std::shared_ptr;
 using std::string;
+using boost::optional;
 using dcp::raw_convert;
 using namespace dcpomatic;
 
@@ -63,6 +66,8 @@ StringTextFileContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job
        Content::examine (film, job);
        StringTextFile file (shared_from_this());
 
+       only_text()->clear_fonts();
+
        /* Default to turning these subtitles on */
        only_text()->set_use (true);
 
@@ -76,10 +81,15 @@ StringTextFileContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job
        }
 
        for (auto name: names) {
-               /* Make a font for each family name that somebody might later
-                * ask about.
-                */
-               only_text()->add_font(make_shared<Font>(name));
+               optional<boost::filesystem::path> path;
+               if (!name.empty()) {
+                       path = FontConfig::instance()->system_font_with_name(name);
+               }
+               if (path) {
+                       only_text()->add_font(make_shared<Font>(name, *path));
+               } else {
+                       only_text()->add_font(make_shared<Font>(name));
+               }
        }
 
        boost::mutex::scoped_lock lm (_mutex);