Fix typo in log message.
[dcpomatic.git] / src / lib / text_content.cc
index 1e9c609c9cafc92686f36cadad576d7aa6bf4f55..a85b271a88d23dbfca216491e5777e701c720f03 100644 (file)
@@ -445,6 +445,9 @@ TextContent::identifier () const
 void
 TextContent::add_font (shared_ptr<Font> font)
 {
+       boost::mutex::scoped_lock lm(_mutex);
+
+       DCPOMATIC_ASSERT(!get_font_unlocked(font->id()));
        _fonts.push_back (font);
        connect_to_fonts ();
 }
@@ -647,3 +650,36 @@ TextContent::take_settings_from (shared_ptr<const TextContent> c)
        set_language (c->_language);
        set_language_is_additional (c->_language_is_additional);
 }
+
+
+shared_ptr<dcpomatic::Font>
+TextContent::get_font(string id) const
+{
+       boost::mutex::scoped_lock lm(_mutex);
+       return get_font_unlocked(id);
+}
+
+
+shared_ptr<dcpomatic::Font>
+TextContent::get_font_unlocked(string id) const
+{
+       auto iter = std::find_if(_fonts.begin(), _fonts.end(), [&id](shared_ptr<dcpomatic::Font> font) {
+               return font->id() == id;
+       });
+
+       if (iter == _fonts.end()) {
+               return {};
+       }
+
+       return *iter;
+}
+
+
+void
+TextContent::clear_fonts()
+{
+       boost::mutex::scoped_lock lm(_mutex);
+
+       _fonts.clear();
+}
+