Make SSA reader more tolerant of missing styles (DoM #2685). v1.6.45
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Dec 2023 18:37:12 +0000 (19:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Dec 2023 18:37:17 +0000 (19:37 +0100)
src/ssa_reader.cc
test/ssa_reader_test.cc

index dad0f2617215c99b8ef47a0b6656adf5199011e8..416d317650a5f70a97341c289580d1236d6fae0e 100644 (file)
@@ -488,8 +488,16 @@ SSAReader::read (function<optional<string> ()> get_line)
                                                   "they seem to mean literally nothing".  Go figure...
                                                */
                                                trim_left_if (event[i], boost::is_any_of ("*"));
-                                               SUB_ASSERT (styles.find(event[i]) != styles.end());
-                                               style = styles[event[i]];
+                                               /* Use the specified style unless it's not defined, in which case use
+                                                * "Default" (if it exists).
+                                                */
+                                               if (styles.find(event[i]) != styles.end()) {
+                                                       style = styles[event[i]];
+                                               } else if (styles.find("Default") != styles.end()) {
+                                                       style = styles["Default"];
+                                               } else {
+                                                       continue;
+                                               }
                                                sub.font = style->font_name;
                                                sub.font_size = FontSize::from_proportional(static_cast<float>(style->font_size) / play_res_y);
                                                sub.colour = style->primary_colour;
index 3413e969a9614e9ccbee4c31666de18133b48fe5..71eb03a6b05c0d09a30a49d04b0b997ea34789e2 100644 (file)
@@ -173,6 +173,7 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test2)
        test ("dcpsubtest-en.ssa");
        test ("dcpsubtest-en.ssa");
        test ("W_GERMAN_SUBS_grey.ass");
+       test ("XxxHolic (2022) ITA 071223.ass");
 }
 
 #define SUB_START(f, t) \