fix(servo): enable variable fonts so weight/width axes render

Like CSS Grid, Servo's `Preferences::default()` ships
`layout_variable_fonts_enabled: false`. `Servo::new` forwards it to Stylo
(`layout.variable_fonts.enabled`), and with the gate off Stylo ignores
`font-variation-settings` and variable weight/width axes: a variable font
renders only its default instance, so every requested weight looks
identical. Modern sites lean on variable fonts (Inter, Roboto Flex,
system New York/SF), so text rendered at the wrong weight versus Chrome.

servo-fonts already drives variations through HarfBuzz, so enabling the
pref is the real fix. Verified with a `@font-face` page using a variable
font at `font-variation-settings: "wght" 200` vs `"wght" 900`: identical
weight before, distinctly light vs black after.

runtime.rs 473 lines (<500). fmt/audit/clippy clean; software_host real-
Servo test passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-29 14:08:41 -04:00
co-authored by Claude Opus 4.8
parent 585cb25fe3
commit d150da5bd0
+11 -7
View File
@@ -188,16 +188,20 @@ fn install_rustls_provider() {
}
fn ely_servo_preferences() -> Preferences {
// `Preferences::default()` is Servo's conservative *library* default and ships
// CSS Grid off. `Servo::new` forwards prefs to Stylo via `prefs::set`, and with
// `layout.grid.enabled` off Stylo blockifies `display: grid`, collapsing every
// grid container to `display: block` — modern grid layouts stack into one column
// (the "broken" rendering on grid-based sites). The layout path is implemented
// (servo-layout drives `DisplayInside::Grid` through Taffy), so an embedder
// building a browser must enable it, exactly as Servo's own servoshell does.
// `Preferences::default()` is Servo's conservative *library* default: it ships
// modern-layout features off even though servo-layout/Stylo implement them and
// Servo's own servoshell browser enables them. `Servo::new` forwards these to
// Stylo via `prefs::set`, so an embedder building a browser must turn them on or
// pages render wrong:
// - `layout.grid.enabled` off => Stylo blockifies `display: grid`, collapsing
// grid layouts into one stacked column (the "broken" modern-site render).
// - `layout.variable_fonts.enabled` off => `font-variation-settings` and
// variable weight/width axes are ignored, so a variable font only ever
// renders its default instance (every requested weight looks identical).
Preferences {
dom_intersection_observer_enabled: true,
layout_grid_enabled: true,
layout_variable_fonts_enabled: true,
..Preferences::default()
}
}