#[cfg(feature = "fonts-vector-latin")]
mod latin;
#[cfg(feature = "fonts-vector-latin")]
pub use latin::FONT as LATIN;
#[cfg(feature = "fonts-complex")]
mod arabic;
#[cfg(feature = "fonts-complex")]
pub use arabic::FONT as ARABIC;
#[cfg(feature = "fonts-cjk")]
#[cfg_attr(docsrs, doc(cfg(feature = "fonts-cjk")))]
mod cjk;
#[cfg(feature = "fonts-cjk")]
pub use cjk::FONT as CJK;
#[cfg(any(
feature = "fonts-cjk-shard-latin",
feature = "fonts-cjk-shard-symbols",
feature = "fonts-cjk-shard-kana",
feature = "fonts-cjk-shard-fullwidth",
feature = "fonts-cjk-shard-han"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "fonts-cjk-shard-latin",
feature = "fonts-cjk-shard-symbols",
feature = "fonts-cjk-shard-kana",
feature = "fonts-cjk-shard-fullwidth",
feature = "fonts-cjk-shard-han"
)))
)]
pub mod cjk_shards;
#[cfg(all(
feature = "runtime-fonts",
any(
feature = "fonts-cjk-shard-latin",
feature = "fonts-cjk-shard-symbols",
feature = "fonts-cjk-shard-kana",
feature = "fonts-cjk-shard-fullwidth",
feature = "fonts-cjk-shard-han"
)
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
feature = "runtime-fonts",
any(
feature = "fonts-cjk-shard-latin",
feature = "fonts-cjk-shard-symbols",
feature = "fonts-cjk-shard-kana",
feature = "fonts-cjk-shard-fullwidth",
feature = "fonts-cjk-shard-han"
)
)))
)]
pub mod cjk_shard_loader;
#[cfg(feature = "fonts-emoji-color")]
mod emoji;
#[cfg(feature = "fonts-emoji-color")]
pub use emoji::FONT as EMOJI;
mod assets;
pub use assets::*;
#[cfg(feature = "runtime-fonts")]
pub(crate) use assets::invalidate_face_cache;
#[cfg(test)]
mod tests {
use super::*;
#[cfg(any(
feature = "text-shaping",
feature = "fonts-vector-latin",
feature = "fonts-complex",
cjk_outline_face
))]
#[test]
fn the_cached_and_uncached_lookups_agree() {
#[cfg(all(feature = "runtime-fonts", feature = "text-shaping"))]
let _guard = crate::render::text::runtime_fonts::test_lock();
let probes = ['A', 'z', '\u{0}', ' ', '\u{E000}', '\u{4E2D}', '\u{3042}', '\u{1F600}'];
for ch in probes {
let cached = face_for_char(ch);
let uncached = face_for_char_uncached(ch);
assert_eq!(
cached.map(|face| face.name),
uncached.map(|face| face.name),
"cache and un-cached lookup disagree for U+{:04X} ({ch:?})",
ch as u32
);
}
}
#[cfg(any(
feature = "text-shaping",
feature = "fonts-vector-latin",
feature = "fonts-complex",
cjk_outline_face
))]
#[test]
fn a_repeated_lookup_is_stable() {
#[cfg(all(feature = "runtime-fonts", feature = "text-shaping"))]
let _guard = crate::render::text::runtime_fonts::test_lock();
let first = face_for_char('A');
for _ in 0..100 {
assert_eq!(
face_for_char('A').map(|face| face.name),
first.map(|face| face.name),
"the cached answer must not change across repeated lookups"
);
}
}
}