Open SimonSapin opened 5 years ago
My gut tells me that having a "hint" structure could be useful as a parameter to the font selection methods. This hint structure could optionally include an &str
EGC and a language tag. I like the name "hint" because it strongly implies that we can modify the algorithm over time, since the specs are clearly imprecise right now. It will be fine if Servo relies on the details of the matching algorithm of this "hint", but calling it a "hint" suggests to other users of font-kit
that they should not rely on these details, because they're subject to change as the CSS and/or Unicode specifications evolve.
How does that sound?
In CSS, the
serif
,sans-serif
,cursive
,fantasy
, andmonospace
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
https://drafts.csswg.org/css-fonts/#font-style-matching
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 achar
code point, or a&str
grapheme cluster?) be useful to any of the backends? What about an optional language tag?