Use fallback list via dyn trait in FontSystem

This commit is contained in:
tigregalis 2025-03-03 16:14:45 +08:00 committed by Jeremy Soller
parent 4e6d5d731b
commit a67dded054
6 changed files with 142 additions and 20 deletions

View file

@ -2,17 +2,40 @@
use unicode_script::Script;
use super::Fallback;
/// An empty platform-specific font fallback list.
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] {
&[]
}
// Fallbacks to never use
pub fn forbidden_fallback() -> &'static [&'static str] {
fn forbidden_fallback() -> &'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] {
&[]
}