LibGfx+LibWeb: Allow inexact size lookups when requesting scaled fonts

For bitmap fonts, we will often not have an exact match for requested
sizes. Return the closest match instead of a nullptr.

LibWeb is currently the only user of this API. If it needs to be
configurable in the future to only allow exact matches, we can add a
parameter or another method at that time.
This commit is contained in:
Timothy Flynn 2024-05-06 13:12:16 -04:00 committed by Alexander Kalenik
commit 464d7d5858
Notes: sideshowbarker 2024-07-16 22:14:49 +09:00
12 changed files with 17 additions and 18 deletions

View file

@ -2089,11 +2089,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
}
auto found_font = StyleProperties::font_fallback(monospace, bold);
if (auto scaled_fallback_font = found_font->with_size(font_size_in_pt)) {
font_list->add(*scaled_fallback_font);
} else {
font_list->add(*found_font);
}
font_list->add(found_font->with_size(font_size_in_pt));
return font_list;
}