Skip to content

fonts: Support font-feature-settings in @font-face rule descriptor - #45393

Merged
simonwuelker merged 5 commits into
servo:mainfrom
simonwuelker:font-feature-settings-font-face-rule
Jun 5, 2026
Merged

simonwuelker merged 5 commits into
servo:mainfrom
simonwuelker:font-feature-settings-font-face-rule

Conversation

@simonwuelker

@simonwuelker simonwuelker commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Additionally, this bumps stylo to servo/stylo#382. I can do that in a seperate PR if preferred, but the change is so small that it doesn't feel like its worth the effort.

Testing: New tests start to pass

@simonwuelker
simonwuelker requested a review from nicoburns as a code owner June 4, 2026 20:18
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 4, 2026
@codecov-commenter

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
924 1 923 0
View the top 1 failed test(s) by shortest run time
servo::webview::test_preferences_change
Stack Traces | 0.262s run time
thread 'test_preferences_change' (93371) panicked at .../servo/tests/webview.rs:1082:5:
assertion `left == right` failed
  left: Ok(Array([String("1"), String("3")]))
 right: Err(EvaluationFailure(None))
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jun 4, 2026
Signed-off-by: Simon Wülker <[email protected]>
Signed-off-by: Simon Wülker <[email protected]>

@shubhamg13 shubhamg13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we copy the comment from Specs as it is. Seems more meaningful.

Comment thread components/fonts/shapers/mod.rs Outdated
fn compute_used_font_features(options: &ShapingOptions) -> impl Iterator<Item = (Tag, u32)> {
/// Determine which OpenType features are applied for the font.
///
/// The order of precedence is specified in <https://drafts.csswg.org/css-fonts-4/#apply-font-matching-variations>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The order of precedence is specified in <https://drafts.csswg.org/css-fonts-4/#apply-font-matching-variations>.
/// General and font specific font feature property settings are resolved in the order below, in ascending order of precedence.
///
/// The order of precedence is specified in <https://drafts.csswg.org/css-fonts-4/#apply-font-matching-variations>.

@simonwuelker simonwuelker Jun 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Writing "[..] are resolved in the order below, in ascending order of precedence" right before "The order of precedence is specified in [..]" reads odd, and I don't see what value that sentence adds here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The order of precedence is specified in <https://drafts.csswg.org/css-fonts-4/#apply-font-matching-variations>.
/// The order of precedence for resolving font-specific font feature properties is specified in <https://drafts.csswg.org/css-fonts-4/#apply-font-matching-variations>.

Looks little ambiguous, what precedence we are targeting. If this looks fine to you. Otherwise 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense, thank you (:

@simonwuelker

Copy link
Copy Markdown
Member Author

Can we copy the comment from Specs as it is. Seems more meaningful.

In this case the spec algorithm computes both font variations (wght, slnt) and font features (liga, hist), but the code is only concerned with font features. There's not much point in adding the variation-related spec steps imo.

@simonwuelker

Copy link
Copy Markdown
Member Author

The unit test failed because my stylo branch was not based on the latest commit.

Signed-off-by: Simon Wülker <[email protected]>
@simonwuelker
simonwuelker force-pushed the font-feature-settings-font-face-rule branch from 2f07afe to a2c702c Compare June 5, 2026 12:55
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 5, 2026
Signed-off-by: Simon Wülker <[email protected]>
@simonwuelker
simonwuelker enabled auto-merge June 5, 2026 12:56
@simonwuelker
simonwuelker added this pull request to the merge queue Jun 5, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 5, 2026
Merged via the queue into servo:main with commit c4019bf Jun 5, 2026
30 checks passed
@simonwuelker
simonwuelker deleted the font-feature-settings-font-face-rule branch June 5, 2026 14:08
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants