diff options
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Properties.json | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleResolver.cpp | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index 3344ea6538..321be3919f 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -188,6 +188,14 @@ "inherited": false, "initial": "none" }, + "font": { + "longhands": [ + "font-family", + "font-size", + "font-variant", + "font-weight" + ] + }, "font-family": { "inherited": true, "initial": "sans-serif" diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp index c101a1ad40..0d55ec9218 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -664,6 +664,28 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } + // FIXME: parse other values as well + if (property_id == CSS::PropertyID::Font) { + auto parts = split_on_whitespace(value.to_string()); + if (parts.size() < 2) + return; + auto size_parts = parts[0].split_view('/'); + if (size_parts.size() == 2) { + auto size = parse_css_value(context, size_parts[0]); + if (!size) + return; + style.set_property(CSS::PropertyID::FontSize, size.release_nonnull()); + } else if (size_parts.size() == 1) { + auto size = parse_css_value(context, parts[0]); + if (!size) + return; + style.set_property(CSS::PropertyID::FontSize, size.release_nonnull()); + } + auto family = parse_css_value(context, parts[1]); + style.set_property(CSS::PropertyID::FontFamily, family.release_nonnull()); + return; + } + style.set_property(property_id, value); } |