1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibWeb+Base: Enable calc() for font-weight property :^)

Modified the test-page because FontDatabase looks for exact font-weight
matches, so requesting weight 800 in a font that only has 700, causes
it to return the default font instead. So, we ask for 700 here.

The actual fix is to improve our font-matching but I am trying not to
get distracted today. :^)
This commit is contained in:
Sam Atkins 2022-01-27 15:54:38 +00:00 committed by Andreas Kling
parent 2407a03fd9
commit 8bd1854406
2 changed files with 7 additions and 3 deletions

View file

@ -714,8 +714,11 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
weight = Gfx::FontWeight::Bold;
else
weight = Gfx::FontWeight::Black;
} else if (font_weight->is_calculated()) {
auto maybe_weight = font_weight->as_calculated().resolve_integer();
if (maybe_weight.has_value())
weight = maybe_weight.value();
}
// FIXME: calc() for font-weight
bool bold = weight > Gfx::FontWeight::Regular;
@ -777,6 +780,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
}
if (maybe_length.has_value()) {
// FIXME: Support font-size: calc(...)
// Theoretically we can do this now, but to resolve it we need a layout_node which we might not have. :^(
if (!maybe_length->is_calculated()) {
auto px = maybe_length.value().to_px(viewport_rect, font_metrics, root_font_size);
if (px != 0)