fonts+layout: Support font-variant-alternates - #45308
Conversation
| // interface CSSFontFeatureValuesMap { | ||
| // maplike<CSSOMString, sequence<unsigned long>>; | ||
| // undefined set(CSSOMString featureValueName, | ||
| // (unsigned long or sequence<unsigned long>) values); |
There was a problem hiding this comment.
This interface is completely stubbed and only exists in this change because we'd run into an unimplemented!() inside cssrule.rs otherwise. There's nothing interesting here.
font-variant-alternatesfont-variant-alternates for freetype systems
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
89d67fa to
16679ba
Compare
|
🔨 Triggering try run (#26823561905) for Linux (WPT) |
16679ba to
05d237d
Compare
|
Test results for linux-wpt from try job (#26823561905): Flaky unexpected result (51)
Stable unexpected results that are known to be intermittent (16)
Stable unexpected results (3)
|
|
|
05d237d to
d4b9d80
Compare
mrobinson
left a comment
There was a problem hiding this comment.
I haven't had time to look at the context.rs changes in detail, but some initial comments below. And one, more general question: Fonts can have multiple, localized family names. Is this API supposed to work with all localized names or just the first name listed in the font tables?
I don't think so. At least in gecko they only consider one single family name: |
Skrifa has a function that first looks for |
2fc0dc4 to
8296054
Compare
Unfortunately we can't use this without a a I've written essentially the same but fully platform independent. Footnotes |
font-variant-alternates for freetype systemsfont-variant-alternates
8296054 to
7d37a5f
Compare
I was more suggesting that we might want to use the same algorithm. That being said, the Fontations project are generally quite open to small PRs, so if you wanted to PR a constructor that takes |
2b7bd5e to
0ba4679
Compare
0ba4679 to
729f613
Compare
Signed-off-by: Simon Wülker <[email protected]>
Signed-off-by: Simon Wülker <[email protected]>
729f613 to
af4b46c
Compare
servo#377) Servo PR: servo/servo#45308 --------- Signed-off-by: Simon Wülker <[email protected]>
This change is more complicated than the other
font-variant-*related PRs becausefont-variant-alternatesrequires the@font-feature-valuesrule to work.I've added a
FontFeatureValuesMaptoLayoutContextto efficiently map from identifiers infont-variant-alternatesto the font-specific indices. This map is lazily initialized when needed and invalidated whenever the stylesheets change.To correctly perform lookups into the map we also need to compute the family name for a given font. This is platform specific code and I don't have access to macos/windows, so we only support freetype for now. Presumably adding support for more platforms would not be difficult. Note that for web fonts the property is supported on all systems, because those specify
font-familyinside the@font-facerule.Testing: New tests start to pass
Depends on servo/stylo#377