From b1ee539e9dbd82a538f0c2c91d4b8546c25e75fe Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Mon, 19 May 2025 21:10:39 +0200 Subject: [PATCH] LibWeb: Fix font-style to slope conversion In a recent refactor of font styles, the new FontStyleStyleValue was introduced; however, the `to_font_slope()` function was not changed to understand this new type. When it tries to convert such a font style to a keyword, it fails. We then rendered the wrong font-style. --- Libraries/LibWeb/CSS/CSSStyleValue.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 6157a2d06f7..db0a928b68a 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -457,7 +457,21 @@ int CSSStyleValue::to_font_slope() const return oblique_slope; case Keyword::Normal: default: - break; + static int normal_slope = Gfx::name_to_slope("Normal"sv); + return normal_slope; + } + } else if (is_font_style()) { + switch (as_font_style().font_style()) { + case FontStyle::Italic: + static int italic_slope = Gfx::name_to_slope("Italic"sv); + return italic_slope; + case FontStyle::Oblique: + static int oblique_slope = Gfx::name_to_slope("Oblique"sv); + return oblique_slope; + case FontStyle::Normal: + default: + static int normal_slope = Gfx::name_to_slope("Normal"sv); + return normal_slope; } } static int normal_slope = Gfx::name_to_slope("Normal"sv);