Also detect fonts used in drawings in font collector

This commit is contained in:
arch1t3cht 2023-04-07 18:49:09 +02:00
parent 15d215f36d
commit 43d65b906b
2 changed files with 8 additions and 1 deletions

View File

@ -139,6 +139,8 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
break; break;
} }
case AssBlockType::DRAWING: case AssBlockType::DRAWING:
used_styles[style].drawing = true;
break;
case AssBlockType::COMMENT: case AssBlockType::COMMENT:
break; break;
} }
@ -146,7 +148,11 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) {
} }
void FontCollector::ProcessChunk(std::pair<StyleInfo, UsageData> const& style) { void FontCollector::ProcessChunk(std::pair<StyleInfo, UsageData> const& style) {
if (style.second.chars.empty()) return; if (style.second.chars.empty() && !style.second.drawing) return;
if (style.second.chars.empty() && style.second.drawing) {
status_callback(fmt_tl("Font '%s' is used in a drawing, but not in any text.\n", style.first.facename), 3);
}
auto res = lister.GetFontPaths(style.first.facename, style.first.bold, style.first.italic, style.second.chars); auto res = lister.GetFontPaths(style.first.facename, style.first.bold, style.first.italic, style.second.chars);

View File

@ -127,6 +127,7 @@ class FontCollector {
/// Data about where each style is used /// Data about where each style is used
struct UsageData { struct UsageData {
std::vector<int> chars; ///< Characters used in this style which glyphs will be needed for std::vector<int> chars; ///< Characters used in this style which glyphs will be needed for
bool drawing = false; ///< Whether this style is used for a drawing
std::vector<int> lines; ///< Lines on which this style is used via overrides std::vector<int> lines; ///< Lines on which this style is used via overrides
std::vector<std::string> styles; ///< ASS styles which use this style std::vector<std::string> styles; ///< ASS styles which use this style
}; };