From f68a99a93b7a735d9983d8946f058a71f5b11cd4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 May 2023 23:12:40 +0200 Subject: Make it possible to write subtitle assets without any tags. --- src/subtitle_asset.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/subtitle_asset.cc') diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index f35b47ef..176ee02b 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -662,11 +662,21 @@ SubtitleAsset::pull_fonts (shared_ptr part) } +void +SubtitleAsset::clear_fonts(shared_ptr part) +{ + part->font.clear(); + for (auto child: part->children) { + clear_fonts(child); + } +} + + /** @param standard Standard (INTEROP or SMPTE); this is used rather than putting things in the child * class because the differences between the two are fairly subtle. */ void -SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, Standard standard) const +SubtitleAsset::subtitles_as_xml(xmlpp::Element* xml_root, int time_code_rate, Standard standard, FontTags fonts) const { auto sorted = _subtitles; std::stable_sort(sorted.begin(), sorted.end(), SubtitleSorter()); @@ -741,9 +751,12 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, S } } - /* Pull font changes as high up the hierarchy as we can */ - - pull_fonts (root); + if (fonts == FontTags::INCLUDE) { + /* Pull font changes as high up the hierarchy as we can */ + pull_fonts(root); + } else { + clear_fonts(root); + } /* Write XML */ -- cgit v1.2.3