diff --git a/examples/text/Cargo.toml b/examples/text/Cargo.toml index f1472446..390e326d 100644 --- a/examples/text/Cargo.toml +++ b/examples/text/Cargo.toml @@ -7,6 +7,7 @@ publish = false [dependencies] ab_glyph = { version = "0.2", optional = true } +env_logger = "0.9" fontdb = "0.9" log = "0.4" orbclient = "0.3" @@ -14,8 +15,10 @@ memmap2 = "0.5" rusttype = { version = "0.9", optional = true } rustybuzz = "0.5" swash = { version = "0.1", optional = true } +sys-locale = "0.2" unicode-bidi = "0.3" unicode-linebreak = "0.1" +unicode-script = "0.5" [features] default = ["swash"] diff --git a/examples/text/res/han.txt b/examples/text/res/han.txt new file mode 100644 index 00000000..86332e04 --- /dev/null +++ b/examples/text/res/han.txt @@ -0,0 +1,29 @@ +https://en.wikipedia.org/wiki/Han_unification#Examples_of_language-dependent_glyphs +今 +令 +免 +入 +全 +关 +具 +刃 +化 +外 +情 +才 +抵 +次 +海 +画 +直 +真 +示 +神 +空 +者 +草 +蔥 +角 +道 +雇 +骨 diff --git a/examples/text/src/buffer.rs b/examples/text/src/buffer.rs index 9cdaa862..f10fcb90 100644 --- a/examples/text/src/buffer.rs +++ b/examples/text/src/buffer.rs @@ -67,7 +67,7 @@ impl<'a> TextBuffer<'a> { let duration = instant.elapsed(); if reshaped > 0 { - eprintln!("shape_until {}: {:?}", reshaped, duration); + log::debug!("shape_until {}: {:?}", reshaped, duration); } } @@ -84,7 +84,7 @@ impl<'a> TextBuffer<'a> { } let duration = instant.elapsed(); - eprintln!("reshape line {}: {:?}", line_i.get(), duration); + log::debug!("reshape line {}: {:?}", line_i.get(), duration); self.relayout_line(line_i); } @@ -106,7 +106,7 @@ impl<'a> TextBuffer<'a> { self.redraw = true; let duration = instant.elapsed(); - eprintln!("relayout: {:?}", duration); + log::debug!("relayout: {:?}", duration); } pub fn relayout_line(&mut self, line_i: FontLineIndex) { @@ -139,7 +139,7 @@ impl<'a> TextBuffer<'a> { self.redraw = true; let duration = instant.elapsed(); - eprintln!("relayout line {}: {:?}", line_i.get(), duration); + log::debug!("relayout line {}: {:?}", line_i.get(), duration); } pub fn font_size(&self) -> i32 { diff --git a/examples/text/src/font/fallback/macos.rs b/examples/text/src/font/fallback/macos.rs new file mode 100644 index 00000000..f13e8798 --- /dev/null +++ b/examples/text/src/font/fallback/macos.rs @@ -0,0 +1,11 @@ +use unicode_script::Script; + +// Fallbacks to use after any script specific fallbacks +pub fn common_fallback() -> &'static [&'static str] { + &[] +} + +// Fallbacks to use per script +pub fn script_fallback(script: &Script, locale: &str) -> &'static [&'static str] { + &[] +} diff --git a/examples/text/src/font/fallback/mod.rs b/examples/text/src/font/fallback/mod.rs new file mode 100644 index 00000000..4551b015 --- /dev/null +++ b/examples/text/src/font/fallback/mod.rs @@ -0,0 +1,86 @@ +use unicode_script::Script; + +use super::Font; + +#[cfg(not(any(macos, unix, windows)))] +use self::other::*; +#[cfg(not(any(macos, unix, windows)))] +mod other; + +#[cfg(macos)] +use self::macos::*; +#[cfg(macos)] +mod macos; + +#[cfg(unix)] +use self::unix::*; +#[cfg(unix)] +mod unix; + +#[cfg(windows)] +use self::windows::*; +#[cfg(windows)] +mod windows; + +pub struct FontFallbackIter<'a> { + fonts: &'a [Font<'a>], + locale: &'a str, + scripts: Vec