linebender / linebender/parley

Font Fallback not working for at least `汉` on Windows

Open
#644 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug C-fontique
Dominant language
Rust
Stars
736
Forks
120
Avg merge
1d 3h
Merged PRs (30d)
53

Description

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:

```rust
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:
https://github.com/linebender/parley/blob/8294d3e50d48e14dbd8be7982d8d4548996ef561/fontique/src/script.rs#L112

though apparently for DirectWrite only a single font is queried anyway, so it wouldn't be the only thing that needs to be fixed.
https://github.com/linebender/parley/blob/8294d3e50d48e14dbd8be7982d8d4548996ef561/fontique/src/backend/dwrite.rs#L200

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fontique/src/script.rs at the fallback character coverage and in fontique/src/backend/dwrite.rs at the DirectWrite font query. Reproduce the Windows case with the provided Rust snippet, then inspect the returned families and charmap result for 汉. Done means the fallback path returns a font whose charmap contains 汉, including the DirectWrite path.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.