Skip to content

Commit

Permalink
Support override fonts (crunchy-labs#378)
Browse files Browse the repository at this point in the history
* Support override fonts

* Compile fix

* Actual compile fix

* Use snake_case
  • Loading branch information
NightQuest authored and Frooastside committed Apr 19, 2024
1 parent aed158d commit e9a0e6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crunchy-cli-core/src/utils/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ const FONTS: [(&str, &str); 68] = [
("Webdings", "webdings.woff2"),
];
lazy_static::lazy_static! {
static ref FONT_REGEX: Regex = Regex::new(r"(?m)^Style:\s.+?,(?P<font>.+?),").unwrap();
static ref FONT_REGEX: Regex = Regex::new(r"(?m)^(?:Style:\s.+?,(?P<font>.+?),|(?:Dialogue:\s(?:.+?,)+,\{(?:\\.*)?\\fn(?P<overrideFont>[\w\s]+)(?:\\.*)?)\})").unwrap();
}

/// Get the fonts used in the subtitle.
Expand All @@ -1309,6 +1309,12 @@ fn get_subtitle_stats(path: &Path) -> Result<Vec<String>> {
fonts.push(font_string)
}
}
if let Some(override_font) = capture.name("overrideFont") {
let font_string = override_font.as_str().to_string();
if !fonts.contains(&font_string) {
fonts.push(font_string)
}
}
}

Ok(fonts)
Expand Down

0 comments on commit e9a0e6c

Please sign in to comment.