diff --git a/Base/res/html/misc/fonts.html b/Base/res/html/misc/fonts.html
index 02381a9f7f..34c2ab1284 100644
--- a/Base/res/html/misc/fonts.html
+++ b/Base/res/html/misc/fonts.html
@@ -31,6 +31,7 @@
font: normal small-caps 120%/120% monospace;
font: condensed oblique 12pt "Helvetica Neue", serif;
font: condensed oblique 25deg 12pt "Helvetica Neue", serif;
+ font-style: italic
Calc() values
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 37cf614378..d14fac4065 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -11,6 +11,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -679,11 +680,13 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
// FIXME: This should be more sophisticated.
compute_defaulted_property_value(style, element, CSS::PropertyID::FontFamily);
compute_defaulted_property_value(style, element, CSS::PropertyID::FontSize);
+ compute_defaulted_property_value(style, element, CSS::PropertyID::FontStyle);
compute_defaulted_property_value(style, element, CSS::PropertyID::FontWeight);
auto viewport_rect = document().browsing_context()->viewport_rect();
auto font_size = style.property(CSS::PropertyID::FontSize).value();
+ auto font_style = style.property(CSS::PropertyID::FontStyle).value();
auto font_weight = style.property(CSS::PropertyID::FontWeight).value();
int weight = Gfx::FontWeight::Regular;
@@ -789,20 +792,35 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
}
}
+ int slope = Gfx::name_to_slope("Normal");
+ // FIXME: Implement oblique
+ if (font_style->is_identifier()) {
+ switch (static_cast(*font_style).id()) {
+ case CSS::ValueID::Italic:
+ slope = Gfx::name_to_slope("Italic");
+ break;
+ case CSS::ValueID::Oblique:
+ slope = Gfx::name_to_slope("Oblique");
+ break;
+ case CSS::ValueID::Normal:
+ default:
+ break;
+ }
+ }
+
// FIXME: Implement the full font-matching algorithm: https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm
// Note: This is modified by the find_font() lambda
FontSelector font_selector;
bool monospace = false;
- // FIXME: Implement font slope style. All found fonts are currently hard-coded as regular.
auto find_font = [&](String const& family) -> RefPtr {
- font_selector = { family, size, weight, 0 };
+ font_selector = { family, size, weight, slope };
if (auto found_font = FontCache::the().get(font_selector))
return found_font;
- if (auto found_font = Gfx::FontDatabase::the().get(family, size, weight, 0))
+ if (auto found_font = Gfx::FontDatabase::the().get(family, size, weight, slope))
return found_font;
return {};