From e0bfb2d4df774519a9ffb3c459711acadcef3fbd Mon Sep 17 00:00:00 2001 From: Amelia Date: Thu, 11 Apr 2024 18:14:27 -0700 Subject: [PATCH] Support override fonts --- crunchy-cli-core/src/utils/download.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crunchy-cli-core/src/utils/download.rs b/crunchy-cli-core/src/utils/download.rs index daae9a5..a9e6ab7 100644 --- a/crunchy-cli-core/src/utils/download.rs +++ b/crunchy-cli-core/src/utils/download.rs @@ -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.+?),").unwrap(); + static ref FONT_REGEX: Regex = Regex::new(r"(?m)^(?:Style:\s.+?,(?P.+?),|(?:Dialogue:\s(?:.+?,)+,\{(?:\\.*)?\\fn(?P[\w\s]+)(?:\\.*)?)\})").unwrap(); } /// Get the fonts used in the subtitle. @@ -1303,7 +1303,7 @@ fn get_subtitle_stats(path: &Path) -> Result> { let mut fonts = vec![]; for capture in FONT_REGEX.captures_iter(&(fs::read_to_string(path)?)) { - if let Some(font) = capture.name("font") { + if let Some(font) = (capture.name("font") || capture.name("overrideFont")) { let font_string = font.as_str().to_string(); if !fonts.contains(&font_string) { fonts.push(font_string)