diff options
| author | Leedehai <18319900+Leedehai@users.noreply.github.com> | 2024-08-05 06:02:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 10:02:48 +0000 |
| commit | 5e187a5d050a8c00a136e2db59a9f072aa14310e (patch) | |
| tree | 359a60058fc2b963761c8a92684466afd7442d41 | |
| parent | d769b21356665da50fbe4e7ef69fd20a1ef2363b (diff) | |
Add font exceptions for Kaiti SC and Kaiti TC (#4616)
| -rw-r--r-- | crates/typst/src/text/font/exceptions.rs | 16 | ||||
| -rw-r--r-- | crates/typst/src/text/font/variant.rs | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/crates/typst/src/text/font/exceptions.rs b/crates/typst/src/text/font/exceptions.rs index 642b6ea7..9234d76c 100644 --- a/crates/typst/src/text/font/exceptions.rs +++ b/crates/typst/src/text/font/exceptions.rs @@ -44,12 +44,14 @@ pub fn find_exception(postscript_name: &str) -> Option<&'static Exception> { /// A map which keys are PostScript name and values are override entries. static EXCEPTION_MAP: phf::Map<&'static str, Exception> = phf::phf_map! { - // The old version of Arial-Black, published by Microsoft in 1996 in their "core fonts for the web" project, has a wrong weight of 400. + // The old version of Arial-Black, published by Microsoft in 1996 in their + // "core fonts for the web" project, has a wrong weight of 400. // See https://corefonts.sourceforge.net/. "Arial-Black" => Exception::new() .weight(900), - // Archivo Narrow is different from Archivo and Archivo Black. Since Archivo Black seems - // identical to Archivo weight 900, only differentiate between Archivo and Archivo Narrow. + // Archivo Narrow is different from Archivo and Archivo Black. Since Archivo Black + // seems identical to Archivo weight 900, only differentiate between Archivo and + // Archivo Narrow. "ArchivoNarrow-Regular" => Exception::new() .family("Archivo Narrow"), "ArchivoNarrow-Italic" => Exception::new() @@ -321,4 +323,12 @@ static EXCEPTION_MAP: phf::Map<&'static str, Exception> = phf::phf_map! { .family("Latin Modern Sans 12"), "LMSans17-Oblique" => Exception::new() .family("Latin Modern Sans 17"), + // STKaiti is a set of Kai fonts. Their weight values need to be corrected + // according to their PostScript names. + "STKaitiSC-Regular" => Exception::new().weight(400), + "STKaitiTC-Regular" => Exception::new().weight(400), + "STKaitiSC-Bold" => Exception::new().weight(700), + "STKaitiTC-Bold" => Exception::new().weight(700), + "STKaitiSC-Black" => Exception::new().weight(900), + "STKaitiTC-Black" => Exception::new().weight(900), }; diff --git a/crates/typst/src/text/font/variant.rs b/crates/typst/src/text/font/variant.rs index b798426f..c7a00fb3 100644 --- a/crates/typst/src/text/font/variant.rs +++ b/crates/typst/src/text/font/variant.rs @@ -79,6 +79,8 @@ impl From<usvg::FontStyle> for FontStyle { #[serde(transparent)] pub struct FontWeight(pub(super) u16); +/// Font weight names and numbers. +/// See `<https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight#common_weight_name_mapping>` impl FontWeight { /// Thin weight (100). pub const THIN: Self = Self(100); |
