From 2d89772ba5b5bc3b2e010b3bbbafe2efa9300353 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 7 Jun 2024 21:09:03 +0200 Subject: Fix font ID allocation from DCP when there are subs and ccaps using the same IDs (#2822). Previously we would always use _id as a disambiguated ID for every case. --- test/font_id_allocator_test.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/font_id_allocator_test.cc b/test/font_id_allocator_test.cc index 7c93c6b78..07110346b 100644 --- a/test/font_id_allocator_test.cc +++ b/test/font_id_allocator_test.cc @@ -23,6 +23,10 @@ #include +using std::string; +using std::vector; + + BOOST_AUTO_TEST_CASE(font_id_allocator_test_without_disambiguation) { FontIDAllocator allocator; @@ -70,3 +74,28 @@ BOOST_AUTO_TEST_CASE(font_id_allocator_test_with_disambiguation) BOOST_CHECK(allocator.font_id(1, "asset3", "font1") == "1_font1"); } + +/* Bug #2822: multiple reels, each with subs + closed captions, and each using the same + * basic font ID. + */ +BOOST_AUTO_TEST_CASE(font_id_allocator_test_with_disambiguation2) +{ + FontIDAllocator allocator; + + allocator.add_font(0, "asset1", "font"); + allocator.add_font(0, "asset2", "font"); + + allocator.add_font(1, "asset1", "font"); + allocator.add_font(1, "asset2", "font"); + + allocator.allocate(); + vector ids = { + allocator.font_id(0, "asset1", "font"), + allocator.font_id(0, "asset2", "font"), + allocator.font_id(1, "asset1", "font"), + allocator.font_id(1, "asset2", "font") + }; + + std::sort(ids.begin(), ids.end()); + BOOST_CHECK(std::adjacent_find(ids.begin(), ids.end()) == ids.end()); +} -- cgit v1.2.3