forked from mia/Aegisub
Support styles after the dialogue in the fonts collector
Make two passes over the file to collect all of the styles before processing the dialogue lines, as the styles section can legally come after the dialogue lines which use those styles.
This commit is contained in:
parent
a5ac77368c
commit
d7b01edc64
1 changed files with 12 additions and 11 deletions
|
@ -29,6 +29,8 @@
|
|||
#include "ass_style.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <libaegisub/of_type_adaptor.h>
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -154,19 +156,18 @@ std::vector<wxString> FontCollector::GetFontPaths(const AssFile *file) {
|
|||
|
||||
status_callback(_("Parsing file\n"), 0);
|
||||
|
||||
int index = 0;
|
||||
for (auto const& line : file->Line) {
|
||||
if (const AssStyle *style = dynamic_cast<const AssStyle*>(&line)) {
|
||||
StyleInfo &info = styles[style->name];
|
||||
info.facename = style->font;
|
||||
info.bold = style->bold;
|
||||
info.italic = style->italic;
|
||||
used_styles[info].styles.insert(style->name);
|
||||
}
|
||||
else if (const AssDialogue *diag = dynamic_cast<const AssDialogue*>(&line))
|
||||
ProcessDialogueLine(diag, ++index);
|
||||
for (auto style : file->Line | agi::of_type<const AssStyle>()) {
|
||||
StyleInfo &info = styles[style->name];
|
||||
info.facename = style->font;
|
||||
info.bold = style->bold;
|
||||
info.italic = style->italic;
|
||||
used_styles[info].styles.insert(style->name);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (auto diag : file->Line | agi::of_type<const AssDialogue>())
|
||||
ProcessDialogueLine(diag, ++index);
|
||||
|
||||
status_callback(_("Searching for font files\n"), 0);
|
||||
for_each(used_styles.begin(), used_styles.end(), bind(&FontCollector::ProcessChunk, this, _1));
|
||||
status_callback(_("Done\n\n"), 0);
|
||||
|
|
Loading…
Reference in a new issue