From 3552abdcbb46a23f1e8dd54d6d37e03ba4b165e4 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 13 Oct 2022 14:20:05 -0600 Subject: [PATCH] Add some CJK fonts for windows --- examples/text/src/font/fallback/windows.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/text/src/font/fallback/windows.rs b/examples/text/src/font/fallback/windows.rs index e262ba0..c4d25e7 100644 --- a/examples/text/src/font/fallback/windows.rs +++ b/examples/text/src/font/fallback/windows.rs @@ -12,6 +12,24 @@ pub fn common_fallback() -> &'static [&'static str] { ] } +fn han_unification(locale: &str) -> &'static [&'static str] { + //TODO! + match locale { + // Japan + "ja" => &[], + // Korea + "ko" => &[], + // China + "zh-CN" => &[], + // Hong Kong + "zh-HK" => &[], + // Taiwan + "zh-TW" => &[], + // Simplified Chinese is the default + _ => &[], + } +} + // Fallbacks to use per script pub fn script_fallback(script: &Script, locale: &str) -> &'static [&'static str] { //TODO: better match https://github.com/chromium/chromium/blob/master/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc#L99 @@ -20,10 +38,14 @@ pub fn script_fallback(script: &Script, locale: &str) -> &'static [&'static str] Script::Canadian_Aboriginal => &["Gadugi"], Script::Cherokee => &["Gadugi"], Script::Devanagari => &["Nirmala UI"], + Script::Ethiopic => &["Ebrima"], Script::Gujarati => &["Nirmala UI"], Script::Gurmukhi => &["Nirmala UI"], + Script::Han => han_unification(locale), Script::Hangul => &["Malgun Gothic"], + Script::Hiragana => &["Meiryo"] Script::Kannada => &["Nirmala UI"], + Script::Katakana => &["Meiryo"] Script::Khmer => &["Leelawadee UI"], Script::Lao => &["Leelawadee UI"], Script::Malayalam => &["Nirmala UI"],