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:
@@ -188,16 +188,20 @@ fn install_rustls_provider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ely_servo_preferences() -> Preferences {
|
fn ely_servo_preferences() -> Preferences {
|
||||||
// `Preferences::default()` is Servo's conservative *library* default and ships
|
// `Preferences::default()` is Servo's conservative *library* default: it ships
|
||||||
// CSS Grid off. `Servo::new` forwards prefs to Stylo via `prefs::set`, and with
|
// modern-layout features off even though servo-layout/Stylo implement them and
|
||||||
// `layout.grid.enabled` off Stylo blockifies `display: grid`, collapsing every
|
// Servo's own servoshell browser enables them. `Servo::new` forwards these to
|
||||||
// grid container to `display: block` — modern grid layouts stack into one column
|
// Stylo via `prefs::set`, so an embedder building a browser must turn them on or
|
||||||
// (the "broken" rendering on grid-based sites). The layout path is implemented
|
// pages render wrong:
|
||||||
// (servo-layout drives `DisplayInside::Grid` through Taffy), so an embedder
|
// - `layout.grid.enabled` off => Stylo blockifies `display: grid`, collapsing
|
||||||
// building a browser must enable it, exactly as Servo's own servoshell does.
|
// 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 {
|
Preferences {
|
||||||
dom_intersection_observer_enabled: true,
|
dom_intersection_observer_enabled: true,
|
||||||
layout_grid_enabled: true,
|
layout_grid_enabled: true,
|
||||||
|
layout_variable_fonts_enabled: true,
|
||||||
..Preferences::default()
|
..Preferences::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user