Let FontFaceSet.check() actually verify your list
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
Currently, if you write something like document.fonts.check("tpyo-font", "test text"), it'll return true, since the typo'd font doesn't exist (and thus doesn't need to be loaded), and the text text will be rendered in the browser fallback instead (which also doesn't need to be loaded). Similarly, if you specify the font names correctly, but the unicode-ranges on them are set up so that the test text will be rendered in the browser fallback anyway, it'll also return true.
These special cases are explicitly called out in the method's definition https://drafts.csswg.org/css-font-loading/#font-face-set-check, and they're correct for the use-case the method was designed for (checking if some text will cause a font to start downloading or not), but it's consistently been a minor source of confusion for authors.
It's reasonable to instead want a method that actually answers the question "can this text be rendered by these specific fonts", without letting browser fallback fonts mess around with the answer. See #6798 for an example use-case.
I suggest we add an option-bag final argument to the function, letting you change into this new behavior if desired.
Some details to iron out for the behavior:
- Do we literally just take the existing method's behavior and remove browser fallbacks from consideration? That is, should it still return false if we'd require a currently-unloaded font from the list?
- Or do we have it actually just check the unicode ranges, ignoring the loading status, so you can just tell if a given bit of text is possible to render in its entirety with a given font stack?
- Both, as separate options?
- Should we allow loaded fonts to check their actual character tables, rather than relying solely on unicode-range? #6798 seems like it might want that.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the FontFaceSet.check() definition linked in the issue and review the example use case in #6798. Resolve how the proposed option bag should treat fallback fonts, unloaded fonts, unicode ranges, and character tables, then update the relevant CSS Font Loading specification text and its examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- documentation, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100