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
Browse files Browse the repository at this point in the history
  • Loading branch information
NightQuest authored Apr 12, 2024
1 parent d7dac2a commit e0bfb2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crunchy-cli-core/src/utils/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,15 +1295,15 @@ 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.
fn get_subtitle_stats(path: &Path) -> Result<Vec<String>> {
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)
Expand Down

0 comments on commit e0bfb2d

Please sign in to comment.