Use fallback list via dyn trait in FontSystem
This commit is contained in:
parent
4e6d5d731b
commit
a67dded054
6 changed files with 142 additions and 20 deletions
|
|
@ -2,8 +2,31 @@
|
|||
|
||||
use unicode_script::Script;
|
||||
|
||||
use super::Fallback;
|
||||
|
||||
/// A platform-specific font fallback list, for Windows.
|
||||
pub struct PlatformFallback;
|
||||
|
||||
impl Fallback for PlatformFallback {
|
||||
fn common_fallback(&self) -> &'static [&'static str] {
|
||||
common_fallback()
|
||||
}
|
||||
|
||||
fn forbidden_fallback(&self) -> &'static [&'static str] {
|
||||
forbidden_fallback()
|
||||
}
|
||||
|
||||
fn script_fallback(
|
||||
&self,
|
||||
script: unicode_script::Script,
|
||||
locale: &str,
|
||||
) -> &'static [&'static str] {
|
||||
script_fallback(script, locale)
|
||||
}
|
||||
}
|
||||
|
||||
// Fallbacks to use after any script specific fallbacks
|
||||
pub fn common_fallback() -> &'static [&'static str] {
|
||||
fn common_fallback() -> &'static [&'static str] {
|
||||
//TODO: abstract style (sans/serif/monospaced)
|
||||
&[
|
||||
"Segoe UI",
|
||||
|
|
@ -15,7 +38,7 @@ pub fn common_fallback() -> &'static [&'static str] {
|
|||
}
|
||||
|
||||
// Fallbacks to never use
|
||||
pub fn forbidden_fallback() -> &'static [&'static str] {
|
||||
fn forbidden_fallback() -> &'static [&'static str] {
|
||||
&[]
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +59,7 @@ fn han_unification(locale: &str) -> &'static [&'static str] {
|
|||
}
|
||||
|
||||
// Fallbacks to use per script
|
||||
pub fn script_fallback(script: Script, locale: &str) -> &'static [&'static str] {
|
||||
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
|
||||
match script {
|
||||
Script::Adlam => &["Ebrima"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue