summaryrefslogtreecommitdiff
path: root/src/lib/font_id_allocator.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-13 23:34:35 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-15 10:21:59 +0100
commitdb22f81ccce9e1a5f205e6d8b3c0631fc039a173 (patch)
tree263c2a28165fe5d3cf03bae25d19cd60b0640bfd /src/lib/font_id_allocator.h
parent7a301e22de2a3c47a81ebc4c9f19b68131b482aa (diff)
Fix handling of empty font IDs and default DCP fonts (#2721) (part of #2722).
Previously we used an empty font ID as the default for when a subtitle has no Font, but in #2721 we saw a DCP with an empty font ID which raised an assertion (because we'd already added our default font with the empty ID). Here we try to fix this (and also make the default font correctly be that from the first <LoadFont>).
Diffstat (limited to 'src/lib/font_id_allocator.h')
-rw-r--r--src/lib/font_id_allocator.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/font_id_allocator.h b/src/lib/font_id_allocator.h
index bd99cad63..fe4b9ef07 100644
--- a/src/lib/font_id_allocator.h
+++ b/src/lib/font_id_allocator.h
@@ -27,6 +27,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <boost/optional.hpp>
namespace dcp {
@@ -66,6 +67,11 @@ public:
void allocate();
std::string font_id(int reel_index, std::string asset_id, std::string font_id) const;
+ std::string default_font_id() const;
+
+ bool has_default_font() const {
+ return static_cast<bool>(_default_font);
+ }
private:
void add_fonts_from_asset(int reel_index, std::shared_ptr<const dcp::SubtitleAsset> asset);
@@ -96,6 +102,7 @@ private:
};
std::map<Font, int> _map;
+ boost::optional<Font> _default_font;
};