1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibWeb: Try failed font lookups again without weight and slope

If CSS requests a font that we have loaded, but we didn't associate it
with a specific weight and/or slope, let's still use it if it matches
the family name.

This is a hack until we implement proper CSS font selection.
This commit is contained in:
Andreas Kling 2023-05-25 12:54:01 +02:00
parent f6fae315e3
commit 9c8da4374d

View file

@ -1285,6 +1285,16 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
return found_font;
}
// We couldn't find this font with a specific weight and slope, so try again without them.
// FIXME: This should be replaced by a proper CSS font selection algorithm.
key.weight = 0;
key.slope = 0;
if (auto it = m_loaded_fonts.find(key); it != m_loaded_fonts.end()) {
auto& loader = *it->value;
if (auto found_font = loader.font_with_point_size(font_size_in_pt))
return found_font;
}
if (auto found_font = FontCache::the().get(font_selector))
return found_font;