summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-12-20 23:49:48 +0100
committerCarl Hetherington <cth@carlh.net>2020-12-20 23:49:48 +0100
commitc6665c157bdb6903661d21c571c7d112b54ad8fd (patch)
tree81910900fb9bcee8958674fef3b1fb70f115d14d
parent2b522d0382a6d4534f1504123a9d16700fe50f0a (diff)
Accept fonts as data blocks rather than files.
-rw-r--r--src/interop_subtitle_asset.cc7
-rw-r--r--src/interop_subtitle_asset.h2
-rw-r--r--src/smpte_subtitle_asset.cc4
-rw-r--r--src/smpte_subtitle_asset.h2
-rw-r--r--src/subtitle_asset.h2
-rw-r--r--test/dcp_font_test.cc4
-rw-r--r--test/test.cc3
7 files changed, 12 insertions, 12 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index 316fb08a..c6173a26 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -119,10 +119,11 @@ InteropSubtitleAsset::xml_as_string () const
}
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
diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h
index 4b96c795..b34a2a28 100644
--- a/src/interop_subtitle_asset.h
+++ b/src/interop_subtitle_asset.h
@@ -64,7 +64,7 @@ public:
std::list<boost::shared_ptr<LoadFontNode> > load_font_nodes () const;
- void add_font (std::string load_id, boost::filesystem::path file);
+ void add_font (std::string load_id, dcp::ArrayData data);
std::string xml_as_string () const;
void write (boost::filesystem::path path) const;
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 0ebfcc61..606ef84c 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -527,10 +527,10 @@ SMPTESubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions
}
void
-SMPTESubtitleAsset::add_font (string load_id, boost::filesystem::path file)
+SMPTESubtitleAsset::add_font (string load_id, dcp::ArrayData data)
{
string const uuid = make_uuid ();
- _fonts.push_back (Font (load_id, uuid, file));
+ _fonts.push_back (Font(load_id, uuid, data));
_load_font_nodes.push_back (shared_ptr<SMPTELoadFontNode> (new SMPTELoadFontNode (load_id, uuid)));
}
diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h
index 09cd4634..1f2215a8 100644
--- a/src/smpte_subtitle_asset.h
+++ b/src/smpte_subtitle_asset.h
@@ -75,7 +75,7 @@ public:
std::string xml_as_string () const;
void write (boost::filesystem::path path) const;
void add (boost::shared_ptr<Subtitle>);
- void add_font (std::string id, boost::filesystem::path file);
+ void add_font (std::string id, dcp::ArrayData data);
void set_key (Key key);
void set_content_title_text (std::string t) {
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 063a2dfd..ab909a26 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -94,7 +94,7 @@ public:
}
virtual void add (boost::shared_ptr<Subtitle>);
- virtual void add_font (std::string id, boost::filesystem::path file) = 0;
+ virtual void add_font (std::string id, dcp::ArrayData data) = 0;
std::map<std::string, ArrayData> font_data () const;
std::map<std::string, boost::filesystem::path> font_filenames () const;
diff --git a/test/dcp_font_test.cc b/test/dcp_font_test.cc
index 6a3941f9..5884cbc0 100644
--- a/test/dcp_font_test.cc
+++ b/test/dcp_font_test.cc
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE (interop_dcp_font_test)
dcp::DCP dcp (directory);
shared_ptr<dcp::InteropSubtitleAsset> subs (new dcp::InteropSubtitleAsset ());
- subs->add_font ("theFontId", "test/data/dummy.ttf");
+ subs->add_font ("theFontId", dcp::ArrayData("test/data/dummy.ttf"));
subs->write (directory / "frobozz.xml");
check_file ("test/data/dummy.ttf", "build/test/interop_dcp_font_test/dummy.ttf");
@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE (smpte_dcp_font_test)
dcp::DCP dcp (directory);
shared_ptr<dcp::SMPTESubtitleAsset> subs (new dcp::SMPTESubtitleAsset ());
- subs->add_font ("theFontId", "test/data/dummy.ttf");
+ subs->add_font ("theFontId", dcp::ArrayData("test/data/dummy.ttf"));
subs->write (directory / "frobozz.mxf");
shared_ptr<dcp::Reel> reel (new dcp::Reel ());
diff --git a/test/test.cc b/test/test.cc
index bace2326..69772e98 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -345,8 +345,7 @@ make_simple_with_interop_subs (boost::filesystem::path path)
boost::filesystem::create_directory (path / "subs");
dcp::ArrayData data(4096);
- data.write (path / "subs" / "font.ttf");
- subs->add_font ("afont", path / "subs" / "font.ttf");
+ subs->add_font ("afont", data);
subs->write (path / "subs" / "subs.xml");
shared_ptr<dcp::ReelSubtitleAsset> reel_subs(new dcp::ReelSubtitleAsset(subs, dcp::Fraction(24, 1), 240, 0));