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 MacOS.
|
||||
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] {
|
||||
&[
|
||||
".SF NS",
|
||||
"Menlo",
|
||||
|
|
@ -14,7 +37,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] {
|
||||
&[".LastResort"]
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +57,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: abstract style (sans/serif/monospaced)
|
||||
//TODO: pull more data from about:config font.name-list.sans-serif in Firefox
|
||||
match script {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue