Fall back to default font file if a font ID is not found in the content.
authorCarl Hetherington <cth@carlh.net>
Mon, 10 Jun 2024 19:39:34 +0000 (21:39 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 11 Jun 2024 07:52:28 +0000 (09:52 +0200)
This should not happen, but seems rather likely given the mess that is
building (especially with users switching between versions).

src/lib/text_decoder.cc

index 75fa33605b0f2f3188f1fc47141a0d609cebd632..945ffaa03121ec58fcc5fde2090dffdc16ea86d8 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "compose.hpp"
+#include "dcpomatic_log.h"
 #include "log.h"
 #include "text_content.h"
 #include "text_decoder.h"
@@ -306,6 +307,10 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & sub_subti
                                );
 
                        auto font = content()->get_font(block.font.get_value_or(""));
+                       if (!font) {
+                               LOG_WARNING("Could not find font '%1' in content; falling back to default", block.font.get_value_or(""));
+                               font = std::make_shared<dcpomatic::Font>(block.font.get_value_or(""), default_font_file());
+                       }
                        DCPOMATIC_ASSERT(font);
 
                        auto string_text = StringText(