diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-24 08:48:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-24 08:48:45 +0100 |
| commit | 79cddd181d1fefa930cf4427b896af5c36758f46 (patch) | |
| tree | c5fab06e1f328d8f39b0b7c7b2fd437149fda0a3 /src/interop_subtitle_asset.cc | |
| parent | f62f5d4514baecbbb7c6821f64d12d89c6f4c385 (diff) | |
Stuff.fontfix
Diffstat (limited to 'src/interop_subtitle_asset.cc')
| -rw-r--r-- | src/interop_subtitle_asset.cc | 27 |
1 files changed, 17 insertions, 10 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 ()))); } } |
