LibWeb+LibWebView: Allow to specify default font size in FontPlugin

Instead of always assuming 12pt size for default font, explicitly pass
it as a parameter.
This commit is contained in:
Aliaksandr Kalenik 2025-01-02 03:56:05 +03:00 committed by Andreas Kling
commit 0b8b690f92
Notes: github-actions[bot] 2025-01-02 09:48:33 +00:00
9 changed files with 22 additions and 24 deletions

View file

@ -43,14 +43,14 @@ void ImageBox::prepare_for_replaced_layout()
set_natural_width(0);
set_natural_height(0);
} else {
auto const& font = Platform::FontPlugin::the().default_font();
auto font = Platform::FontPlugin::the().default_font(12);
CSSPixels alt_text_width = 0;
if (!m_cached_alt_text_width.has_value())
m_cached_alt_text_width = CSSPixels::nearest_value_for(font.width(alt));
m_cached_alt_text_width = CSSPixels::nearest_value_for(font->width(alt));
alt_text_width = m_cached_alt_text_width.value();
set_natural_width(alt_text_width + 16);
set_natural_height(CSSPixels::nearest_value_for(font.pixel_size()) + 16);
set_natural_height(CSSPixels::nearest_value_for(font->pixel_size()) + 16);
}
}