diff --git a/CHANGELOG.md b/CHANGELOG.md index 510c0c0..81a953c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Add support for loading webp images +- Add support for new 'fontin' fonts ### Fixed diff --git a/fonts/fontin-italic.ttf b/fonts/fontin-italic.ttf new file mode 100644 index 0000000..04d21c1 Binary files /dev/null and b/fonts/fontin-italic.ttf differ diff --git a/fonts/fontin-smallcaps.ttf b/fonts/fontin-smallcaps.ttf new file mode 100644 index 0000000..d2771c6 Binary files /dev/null and b/fonts/fontin-smallcaps.ttf differ diff --git a/src/api/rendering.rs b/src/api/rendering.rs index d683599..7fc0ed0 100644 --- a/src/api/rendering.rs +++ b/src/api/rendering.rs @@ -475,6 +475,12 @@ fn build_layout_job<'a>( font_weight = Some(700.0); FontFamily::Named(Cow::Borrowed("Liberation Sans")) } + PoBFontType::FontinItalic => FontFamily::Named(Cow::Borrowed("Fontin")), + PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")), + PoBFontType::FontinSmallcapsItalic => { + // TODO: use regular Smallcaps for now, add "faux italics" later + FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")) + } }; // TODO: check how PoB determines font size @@ -623,6 +629,9 @@ enum PoBFontType { Fixed, Var, VarBold, + FontinSmallcaps, + FontinSmallcapsItalic, + FontinItalic, } impl std::str::FromStr for PoBFontType { @@ -633,6 +642,9 @@ impl std::str::FromStr for PoBFontType { "FIXED" => Ok(Self::Fixed), "VAR" => Ok(Self::Var), "VAR BOLD" => Ok(Self::VarBold), + "FONTIN SC" => Ok(Self::FontinSmallcaps), + "FONTIN SC ITALIC" => Ok(Self::FontinSmallcapsItalic), + "FONTIN ITALIC" => Ok(Self::FontinItalic), _ => Err(anyhow::anyhow!( "'{}' is not a valid TextFontType variant", s diff --git a/src/app.rs b/src/app.rs index 3939e02..d255b7a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -299,6 +299,18 @@ fn pob_font_definitions() -> FontDefinitions { "../fonts/LiberationSans-Bold.ttf" ))), ); + definitions.font_data.insert( + "fontin-italic".to_owned(), + Arc::new(FontData::from_static(include_bytes!( + "../fonts/fontin-italic.ttf" + ))), + ); + definitions.font_data.insert( + "fontin-smallcaps".to_owned(), + Arc::new(FontData::from_static(include_bytes!( + "../fonts/fontin-smallcaps.ttf" + ))), + ); definitions.generic_families.insert( parley::GenericFamily::Monospace, @@ -313,5 +325,10 @@ fn pob_font_definitions() -> FontDefinitions { ], ); + definitions.generic_families.insert( + parley::GenericFamily::Serif, + vec!["fontin-italic".to_owned(), "fontin-smallcaps".to_owned()], + ); + definitions }