Prevent resolve_fonts from adding duplicate fonts to its list.
[libdcp.git] / src / interop_subtitle_asset.cc
index cfd37cb8c85b92171d51a6e0b96c13c9eab81dee..54c27ff5225223ff21ae2489561459864bfb4c16 100644 (file)
@@ -202,7 +202,15 @@ InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Asset> > assets)
                }
 
                BOOST_FOREACH (shared_ptr<InteropLoadFontNode> j, _load_font_nodes) {
-                       if (font->file() && j->uri == font->file()->leaf().string ()) {
+                       bool got = false;
+                       BOOST_FOREACH (Font const & k, _fonts) {
+                               if (k.load_id == j->id) {
+                                       got = true;
+                                       break;
+                               }
+                       }
+                       
+                       if (!got && font->file() && j->uri == font->file()->leaf().string()) {
                                _fonts.push_back (Font (j->id, i->id(), font->file().get()));
                        }
                }