Skip to content

Font Fallback not working for at least on Windows #644

Description

@CryZe

The font family returned by fontique for the Hani script is Yu Gothic UI on Windows, which does not have the character . The character is in Microsoft YaHei UI, which is not returned at all.

Reproduction:

use fontique::{Collection, FallbackKey, Script, SourceCache};

let mut collection = Collection::default();
let mut source_cache = SourceCache::default();
let family_ids: Vec<_> = collection
    .fallback_families(FallbackKey::new(Script::from_bytes(*b"Hani"), None))
    .collect();
let family_names: Vec<_> = family_ids
    .iter()
    .map(|&id| collection.family_name(id).unwrap().to_owned())
    .collect();

println!("fallback families: {family_names:?}");

let family_id = family_ids[0];
let family_name = collection.family_name(family_id).unwrap().to_owned();
let family = collection.family(family_id).unwrap();
let font = family.default_font().unwrap();
let data = font.load(Some(&mut source_cache)).unwrap();
let charmap = font.charmap_index().charmap(data.as_ref()).unwrap();

println!("{family_name}: 汉 -> {:?}", charmap.map('汉'));

The problematic line seems to be here, which doesn't contain enough characters for more coverage:

(Script::from_str_unchecked("Hani"), "今"),

though apparently for DirectWrite only a single font is queried anyway, so it wouldn't be the only thing that needs to be fixed.

fn family_name_for_text(&mut self, text: &str, locale: Option<&str>) -> Option<String> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-fontiqueRelates to the fontique cratebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions