pub const DEJAVU_SANS: &[u8] = include_bytes!("assets/DejaVuSans.ttf");
pub const DEJAVU_SANS_BOLD: &[u8] = include_bytes!("assets/DejaVuSans-Bold.ttf");
pub fn needs_unicode_font(s: &str) -> bool {
s.chars().any(|c| {
let cp = c as u32;
let normalized = super::encoding::math_alphanumeric_base(cp).unwrap_or(cp);
super::encoding::unicode_to_winansi(normalized).is_none()
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn font_bytes_load() {
assert!(DEJAVU_SANS.len() > 100_000, "DejaVu Sans should be ~760KB");
assert!(DEJAVU_SANS_BOLD.len() > 100_000);
assert_eq!(&DEJAVU_SANS[..4], &[0x00, 0x01, 0x00, 0x00]);
}
#[test]
fn ascii_does_not_need_unicode() {
assert!(!needs_unicode_font("Hello, World!"));
}
#[test]
fn smart_quote_in_winansi() {
assert!(!needs_unicode_font("Pearson\u{2019}s"));
}
#[test]
fn greek_needs_unicode() {
assert!(needs_unicode_font("β")); assert!(needs_unicode_font("σ")); }
#[test]
fn math_italic_does_not_need_unicode() {
assert!(!needs_unicode_font("\u{1D465}")); assert!(needs_unicode_font("\u{1D6FD}")); }
}