diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-10-14 21:48:25 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-10-15 09:10:18 +0200 |
| commit | 3c802dd6d1451c2c8a7e188f8379738d72e907eb (patch) | |
| tree | 454396cf5451535b8708a0c4961c7d5c2b30ea1f /src/lib/dcp_examiner.h | |
| parent | 1bfe44b1503fb0f5cffda135076709014337de52 (diff) | |
Fix DCP content font ID allocation to cope with DCPs that have multiple fonts
with the same name in the same reel (#2600).
Previously we had this id_for_font_in_reel() which would give an ID
of N_font-ID. This means we got duplicate font IDs.
Here we replace that method with FontAllocator, which gives an ID of
N_font-ID for the first font and M_font-ID, where M is a number higher than
the highest reel index. The idea is to support the required new IDs
without breaking exisiting projects.
There is some documentation of how it works in doc/design/fonts
Diffstat (limited to 'src/lib/dcp_examiner.h')
| -rw-r--r-- | src/lib/dcp_examiner.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index 1a3615867..54e283548 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -27,6 +27,7 @@ #include "audio_examiner.h" #include "dcp_text_track.h" #include "dcpomatic_assert.h" +#include "font_id_allocator.h" #include "video_examiner.h" #include <dcp/dcp_time.h> #include <dcp/rating.h> @@ -173,10 +174,7 @@ public: return _atmos_edit_rate; } - /** @return fonts in each reel */ - std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> fonts() const { - return _fonts; - } + void add_fonts(std::shared_ptr<TextContent> content); private: boost::optional<double> _video_frame_rate; @@ -211,5 +209,20 @@ private: bool _has_atmos = false; Frame _atmos_length = 0; dcp::Fraction _atmos_edit_rate; - std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> _fonts; + + struct Font + { + Font(int reel_index_, std::string asset_id_, std::shared_ptr<dcpomatic::Font> font_) + : reel_index(reel_index_) + , asset_id(asset_id_) + , font(font_) + {} + + int reel_index; + std::string asset_id; + std::shared_ptr<dcpomatic::Font> font; + }; + + std::vector<Font> _fonts; + FontIDAllocator _font_id_allocator; }; |
