From 4fc20c7c1cc67f4cc06a03120c10b67469210572 Mon Sep 17 00:00:00 2001 From: Amelia Date: Sun, 14 Apr 2024 12:55:55 -0700 Subject: [PATCH] Support override fonts (#378) * Support override fonts * Compile fix * Actual compile fix * Use snake_case --- crunchy-cli-core/src/utils/download.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crunchy-cli-core/src/utils/download.rs b/crunchy-cli-core/src/utils/download.rs index daae9a5..a17875d 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. @@ -1309,6 +1309,12 @@ fn get_subtitle_stats(path: &Path) -> Result> { 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)