Include all coverage variants for a family in a query#663
Conversation
A family may hold several fonts with identical width, style and weight that differ only in unicode coverage, e.g. the per-unicode-range slices of a web font registered under one family name. The query previously surfaced only the single best match plus the family default, so the other slices were never offered to the caller and their codepoints fell back or rendered as tofu. Add matching::match_fonts to collect every font sharing the best match's attributes, and have the query yield the whole set. The caller already walks candidates per cluster against each font's charmap, so it now lands on the slice that covers the cluster. Fixes linebender#322.
The single caller iterates once, so skip the intermediate collection and its allocation when a family spills past four coverage variants.
DJMcNab
left a comment
There was a problem hiding this comment.
I'm happy enough for this to land as-is; it does address a real case fairly surgically.
However, I do have a couple of follow-up questions:
- Is this definitely the right behaviour; we gate the 'later' fonts on being 'exactly as good' as the best match?
- Presumably, a better long-term fix would be to actually implement unicode range support. Would we still need this in that case?
@kane50613, let me know when you're happy and I'll merge it.
|
@DJMcNab Thanks for reviewing and I've guided Claude to research on how Blink does this
|
Fixes #322
Generated with Claude and reviewed by me
Add
matching::match_fontsto collect every font sharing the best match's attributes, and have the query include the whole set. The caller already walks candidates per cluster against each font's charmap, so it now lands on the slice that covers the cluster.