using std::cout;
using std::cerr;
using std::map;
-using boost::shared_ptr;
+using std::shared_ptr;
using boost::shared_array;
using boost::optional;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
using namespace dcp;
InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
}
void
-InteropSubtitleAsset::add_font (string load_id, boost::filesystem::path file)
+InteropSubtitleAsset::add_font (string load_id, dcp::ArrayData data)
{
- _fonts.push_back (Font (load_id, make_uuid(), file));
- _load_font_nodes.push_back (shared_ptr<InteropLoadFontNode> (new InteropLoadFontNode (load_id, file.leaf().string ())));
+ _fonts.push_back (Font(load_id, make_uuid(), data));
+ string const uri = String::compose("font_%1.ttf", _load_font_nodes.size());
+ _load_font_nodes.push_back (shared_ptr<InteropLoadFontNode>(new InteropLoadFontNode(load_id, uri)));
}
bool
return false;
}
- list<shared_ptr<InteropLoadFontNode> >::const_iterator i = _load_font_nodes.begin ();
- list<shared_ptr<InteropLoadFontNode> >::const_iterator j = other->_load_font_nodes.begin ();
+ if (!options.load_font_nodes_can_differ) {
+ list<shared_ptr<InteropLoadFontNode> >::const_iterator i = _load_font_nodes.begin ();
+ list<shared_ptr<InteropLoadFontNode> >::const_iterator j = other->_load_font_nodes.begin ();
- while (i != _load_font_nodes.end ()) {
- if (j == other->_load_font_nodes.end ()) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
- return false;
- }
+ while (i != _load_font_nodes.end ()) {
+ if (j == other->_load_font_nodes.end ()) {
+ note (DCP_ERROR, "<LoadFont> nodes differ");
+ return false;
+ }
- if (**i != **j) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
- return false;
- }
+ if (**i != **j) {
+ note (DCP_ERROR, "<LoadFont> nodes differ");
+ return false;
+ }
- ++i;
- ++j;
+ ++i;
+ ++j;
+ }
}
if (_movie_title != other->_movie_title) {
BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
if (im) {
- Data png_image = im->png_image ();
+ ArrayData png_image = im->png_image ();
pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
}
}
}
+
+
+void
+InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path file)
+{
+ BOOST_FOREACH (Font& i, _fonts) {
+ if (i.load_id == load_id) {
+ i.file = file;
+ }
+ }
+
+ BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
+ if (i->id == load_id) {
+ i->uri = file.filename().string();
+ }
+ }
+}
+