Default Caseless Matching of possibly-localized family names
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 840
- Forks
- 137
- Avg merge
- 4h 56m
- Merged PRs (30d)
- 1
Description
Servo would like to implement CSS on top of font-kit. The spec (relevant bits below):
- Is very specific about (case-insensitive) string comparison for font family names
- Requires accepting alternative (localized) family names of any given font
Source::select_family_by_name looks like the appropriate API for looking up system fonts matching a given family name string. Some research is needed, to figure out whether the underlying APIs (fontconfig/CoreText/DirectWrite) of the respective default Source for each supported platform behaves as CSS requires on these two points, or if can be configured to do so.
An alternative could be to enumerate all available fonts and their family names, and maintain a Rust (hash?) map where keys are normalized with default case fold. But I suspect this would have significant startup cost.
https://drafts.csswg.org/css-fonts/#font-family-casing
User agents must match these names case insensitively, using the "Default Caseless Matching" algorithm outlined in the Unicode specification [UNICODE]. This algorithm is detailed in section 3.13 entitled "Default Case Algorithms". Specifically, the algorithm must be applied without normalizing the strings involved and without applying any language-specific tailorings. The case folding method specified by this algorithm uses the case mappings with status field ‘C’ or ‘F’ in the CaseFolding.txt file of the Unicode Character Database [UNICODE].
[…]
Implementors should take care to verify that a given caseless string comparison implementation uses this precise algorithm and not assume that a given platform string matching routine follows it, as many of these have locale-specific behavior or use some level of string normalization [UAX15].
https://drafts.csswg.org/css-fonts/#font-style-matching
On systems containing fonts with multiple localized font family names, user agents must match any of these names independent of the underlying system locale or platform API used.
https://drafts.csswg.org/css-fonts/#family-name-value
Some font formats allow fonts to carry multiple localizations of the family name. User agents must recognize and correctly match all of these names independent of the underlying platform localization, system API used or document encoding:
![]()
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_name and compare the default font sources on fontconfig, CoreText, and DirectWrite against the CSS requirements for default caseless matching and localized family names. Investigate whether the platform APIs can satisfy both requirements or whether enumerating fonts and their family names is necessary. Done means documenting the platform behavior and selecting a viable implementation approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, rust
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100