Add SubtitleAsset::ensure_font(). v1.8.69
authorCarl Hetherington <cth@carlh.net>
Thu, 11 May 2023 23:35:26 +0000 (01:35 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 11 May 2023 23:35:26 +0000 (01:35 +0200)
src/subtitle_asset.cc
src/subtitle_asset.h

index d6103a1d751c06909d0e5c1a0a53569f9bab935e..5a448f3ffd7727b721738daf9be1a0a70da28a44 100644 (file)
@@ -928,3 +928,12 @@ SubtitleAsset::format_xml(xmlpp::Document const& document, optional<pair<string,
        return state.xml;
 }
 
+
+void
+SubtitleAsset::ensure_font(string load_id, dcp::ArrayData data)
+{
+       if (std::find_if(_fonts.begin(), _fonts.end(), [load_id](Font const& font) { return font.load_id == load_id; }) == _fonts.end()) {
+               add_font(load_id, data);
+       }
+}
+
index 28db957460a68ce9dbb13940a9d825fdf9a015d8..bc5fa8824711cf8d600c6c3763631196916d6e86 100644 (file)
@@ -111,6 +111,7 @@ public:
 
        virtual void add (std::shared_ptr<Subtitle>);
        virtual void add_font (std::string id, dcp::ArrayData data) = 0;
+       void ensure_font(std::string id, dcp::ArrayData data);
        std::map<std::string, ArrayData> font_data () const;
        std::map<std::string, boost::filesystem::path> font_filenames () const;