diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-24 12:11:04 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-24 12:11:04 +0200 |
commit | 10ceacf5fb6ef8cea7c90958470515d5b386c50b (patch) | |
tree | a36ef35553dc47064be3f61635c7a2cd3763ee8e /Userland/Libraries/LibWeb/CSS | |
parent | 81b6723b29dbf159007436f3c4eaf6784df12620 (diff) | |
download | serenity-10ceacf5fb6ef8cea7c90958470515d5b386c50b.zip |
LibWeb: Honor the font-size even if the font-family is not found
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 34e1656b43..514595124f 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1304,8 +1304,9 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele FontSelector font_selector; bool monospace = false; + float const font_size_in_pt = font_size_in_px * 0.75f; + auto find_font = [&](String const& family) -> RefPtr<Gfx::Font const> { - float font_size_in_pt = font_size_in_px * 0.75f; font_selector = { family, font_size_in_pt, weight, width, slope }; if (auto it = m_loaded_fonts.find(family); it != m_loaded_fonts.end()) { @@ -1380,6 +1381,10 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele if (!found_font) { found_font = StyleProperties::font_fallback(monospace, bold); + if (found_font) { + if (auto scaled_fallback_font = found_font->with_size(font_size_in_pt)) + found_font = scaled_fallback_font; + } } FontCache::the().set(font_selector, *found_font); |