From d150da5bd0ba9415be9a479029fd6ebada2a8789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 29 May 2026 14:08:41 -0400 Subject: [PATCH] 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) --- crates/ely_servo_host/src/runtime.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/ely_servo_host/src/runtime.rs b/crates/ely_servo_host/src/runtime.rs index 2a239f6..32ba0f6 100644 --- a/crates/ely_servo_host/src/runtime.rs +++ b/crates/ely_servo_host/src/runtime.rs @@ -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() } }