Looking up CSS generic families
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 840
- Forks
- 137
- Avg merge
- 4h 56m
- Merged PRs (30d)
- 1
Description
In CSS, the serif, sans-serif, cursive, fantasy, and monospace keywords when used without quotes have a different meaning than other keywords (which are space-joined into a single string) or quoted strings. They are "generic" font families.
Currently Source::select_family_by_generic_name allows looking up concrete font families from those keywords, but it is #[doc(hidden)] with a FIXME comment about returning multiple families.
In the specification:
https://drafts.csswg.org/css-fonts/#generic-font-families
All five generic font families must always result in at least one matched font face, for all CSS implementations. However, the generics may be composite faces (with different typefaces based on such things as the Unicode range of the character, the language of the containing element, user preferences and system settings, among others). They are also not guaranteed to always be different from each other.
https://drafts.csswg.org/css-fonts/#font-style-matching
User agents may choose the generic font family to use based on the language of the containing element or the Unicode range of the character.
Based on other uses, the spec appears to misuse "character" to mean Unicode code point. But then “When text contains characters such as combining marks” there’s specific handling based on grouping by grapheme cluster.
So perhaps Source::select_family_by_generic_name should be unhidden, but after some API change. Would an input "character" (perhaps a char code point, or a &str grapheme cluster?) be useful to any of the backends? What about an optional language tag?
Contributor guide
No contributing guide indexed for this repository
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 Source::select_family_by_generic_name and its FIXME, then compare its current behavior with the CSS generic font-family and font-style-matching specifications. Investigate whether code point, grapheme cluster, or language-tag inputs are useful across the backends; done means an agreed API direction for generic-family lookup, rather than an unresolved design question.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100