summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interop_subtitle_asset.cc27
-rw-r--r--src/interop_subtitle_asset.h20
-rw-r--r--src/smpte_subtitle_asset.cc2
-rw-r--r--src/smpte_subtitle_asset.h14
-rw-r--r--src/subtitle_asset.cc16
-rw-r--r--src/subtitle_asset.h24
6 files changed, 51 insertions, 52 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index ffa7d50b..c4c8af0e 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -90,10 +90,10 @@ InteropSubtitleAsset::xml_as_string () const
}
void
-InteropSubtitleAsset::add_font (string id, boost::filesystem::path file)
+InteropSubtitleAsset::add_font (string load_id, string uuid, boost::filesystem::path file)
{
- add_font_data (id, file);
- _load_font_nodes.push_back (shared_ptr<InteropLoadFontNode> (new InteropLoadFontNode (id, file.leaf().string ())));
+ _fonts.push_back (Font (load_id, uuid, file));
+ _load_font_nodes.push_back (shared_ptr<InteropLoadFontNode> (new InteropLoadFontNode (load_id, file.leaf().string ())));
}
bool
@@ -163,11 +163,18 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
if (!f) {
throw FileError ("could not open font file for writing", file, errno);
}
- map<string, FileData>::const_iterator j = _fonts.find (i->id);
+
+ list<Font>::const_iterator j = _fonts.begin ();
+
+ while (j != _fonts.end() && j->load_id != i->id) {
+ ++j;
+ }
+
if (j != _fonts.end ()) {
- fwrite (j->second.data.get(), 1, j->second.size, f);
- j->second.file = file;
+ fwrite (j->data.data.get(), 1, j->data.size, f);
+ j->file = file;
}
+
fclose (f);
}
}
@@ -183,7 +190,7 @@ InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Object> > objects)
BOOST_FOREACH (shared_ptr<InteropLoadFontNode> j, _load_font_nodes) {
if (j->uri == font->file().leaf().string ()) {
- add_font_data (j->id, font->file ());
+ _fonts.push_back (Font (i->id(), j->id, font->file ()));
}
}
}
@@ -192,8 +199,8 @@ InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Object> > objects)
void
InteropSubtitleAsset::add_font_assets (list<shared_ptr<Asset> >& assets)
{
- for (map<string, FileData>::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
- DCP_ASSERT (i->second.file);
- assets.push_back (shared_ptr<FontAsset> (new FontAsset (i->second.file.get ())));
+ for (list<Font>::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
+ DCP_ASSERT (i->file);
+ assets.push_back (shared_ptr<FontAsset> (new FontAsset (i->file.get ())));
}
}
diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h
index 41ed83b3..7c727d69 100644
--- a/src/interop_subtitle_asset.h
+++ b/src/interop_subtitle_asset.h
@@ -47,7 +47,7 @@ public:
std::list<boost::shared_ptr<LoadFontNode> > load_font_nodes () const;
- void add_font (std::string id, boost::filesystem::path file);
+ void add_font (std::string font_id, std::string uuid, boost::filesystem::path file);
Glib::ustring xml_as_string () const;
void write (boost::filesystem::path path) const;
@@ -102,6 +102,24 @@ private:
std::string _language;
std::string _movie_title;
std::list<boost::shared_ptr<InteropLoadFontNode> > _load_font_nodes;
+
+ class Font
+ {
+ public:
+ Font (std::string load_id_, std::string uuid_, boost::filesystem::path file_)
+ : load_id (load_id_)
+ , uuid (uuid_)
+ , data (file_)
+ , file (file_)
+ {}
+
+ std::string load_id;
+ std::string uuid;
+ Data data;
+ mutable boost::optional<boost::filesystem::path> file;
+ };
+
+ std::list<Font> _fonts;
};
}
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 8ea68362..699f589f 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -144,7 +144,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
}
if (j != _load_font_nodes.end ()) {
- _fonts[(*j)->id] = FileData (data, buffer.Size ());
+ _fonts.push_back (Font ((*j)->id,data, buffer.Size ()));
}
}
}
diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h
index 444c53e6..9dee7f6d 100644
--- a/src/smpte_subtitle_asset.h
+++ b/src/smpte_subtitle_asset.h
@@ -130,6 +130,20 @@ private:
int _time_code_rate;
boost::optional<Time> _start_time;
+ class Font
+ {
+ public:
+ Font (std::string uuid_, boost::shared_array<uint8_t> data_, boost::uintmax_t size_)
+ : uuid (uuid_)
+ , data (data_, size_)
+ {}
+
+ std::string uuid;
+ Data data;
+ mutable boost::optional<boost::filesystem::path> file;
+ };
+
+ std::list<Font> _fonts;
std::list<boost::shared_ptr<SMPTELoadFontNode> > _load_font_nodes;
};
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index 367c3455..55fe2af4 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -307,19 +307,3 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, strin
text->add_child_text (i->text());
}
}
-
-void
-SubtitleAsset::add_font_data (string id, boost::filesystem::path file)
-{
- _fonts[id] = FileData (file);
-}
-
-map<string, Data>
-SubtitleAsset::fonts () const
-{
- map<string, Data> out;
- for (map<string, FileData>::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
- out[i->first] = i->second;
- }
- return out;
-}
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 31afecb3..725669f7 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -70,7 +70,6 @@ public:
void add (SubtitleString);
virtual void add_font (std::string id, boost::filesystem::path file) = 0;
- std::map<std::string, Data> fonts () const;
virtual void write (boost::filesystem::path) const = 0;
virtual Glib::ustring xml_as_string () const = 0;
@@ -85,33 +84,10 @@ protected:
void parse_subtitles (boost::shared_ptr<cxml::Document> xml, std::list<boost::shared_ptr<FontNode> > font_nodes);
void subtitles_as_xml (xmlpp::Element* root, int time_code_rate, std::string xmlns) const;
- void add_font_data (std::string id, boost::filesystem::path file);
/** All our subtitles, in no particular order */
std::list<SubtitleString> _subtitles;
- class FileData : public Data {
- public:
- FileData () {}
-
- FileData (boost::shared_array<uint8_t> data_, boost::uintmax_t size_)
- : Data (data_, size_)
- {}
-
- FileData (boost::filesystem::path file_)
- : Data (file_)
- {}
-
- /** .ttf file that this data was last written to */
- mutable boost::optional<boost::filesystem::path> file;
- };
-
- /** Font data, keyed by a subclass-dependent identifier.
- * For Interop, the string is the font ID from the subtitle file.
- * For SMPTE, the string is the font's URN from the subtitle file.
- */
- std::map<std::string, FileData> _fonts;
-
private:
/** @struct ParseState
* @brief A struct to hold state when parsing a subtitle XML file.