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
parent 1be55fe793
commit 0b8b690f92
9 changed files with 22 additions and 24 deletions

View File

@@ -415,7 +415,7 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const
paint_inspector_rect(border_rect, Color::Green);
paint_inspector_rect(content_rect, Color::Magenta);
auto& font = Platform::FontPlugin::the().default_font();
auto font = Platform::FontPlugin::the().default_font(12);
StringBuilder builder;
if (layout_node_with_style_and_box_metrics().dom_node())
@@ -427,12 +427,12 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const
auto size_text_rect = border_rect;
size_text_rect.set_y(border_rect.y() + border_rect.height());
size_text_rect.set_top(size_text_rect.top());
size_text_rect.set_width(CSSPixels::nearest_value_for(font.width(size_text)) + 4);
size_text_rect.set_height(CSSPixels::nearest_value_for(font.pixel_size()) + 4);
size_text_rect.set_width(CSSPixels::nearest_value_for(font->width(size_text)) + 4);
size_text_rect.set_height(CSSPixels::nearest_value_for(font->pixel_size()) + 4);
auto size_text_device_rect = context.enclosing_device_rect(size_text_rect).to_type<int>();
context.display_list_recorder().fill_rect(size_text_device_rect, context.palette().color(Gfx::ColorRole::Tooltip));
context.display_list_recorder().draw_rect(size_text_device_rect, context.palette().threed_shadow1());
context.display_list_recorder().draw_text(size_text_device_rect, size_text, font.with_size(font.point_size() * context.device_pixels_per_css_pixel()), Gfx::TextAlignment::Center, context.palette().color(Gfx::ColorRole::TooltipText));
context.display_list_recorder().draw_text(size_text_device_rect, size_text, font->with_size(font->point_size() * context.device_pixels_per_css_pixel()), Gfx::TextAlignment::Center, context.palette().color(Gfx::ColorRole::TooltipText));
}
}