Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Support override fonts (#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 committed Apr 14, 2024
1 parent 6515d30 commit 4fc20c7
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 4fc20c7

Please sign in to comment.