1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibWeb: Scale the font when painting the text on buttons

Button text was staying the same size at all zoom levels. :^)
This commit is contained in:
Andreas Kling 2023-03-15 22:53:38 +01:00
parent 20132da88d
commit 5146b9b35e
4 changed files with 29 additions and 18 deletions

View file

@ -5,6 +5,7 @@
*/
#include <LibGUI/Event.h>
#include <LibWeb/FontCache.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/Layout/ButtonBox.h>
@ -47,7 +48,12 @@ void ButtonPaintable::paint(PaintContext& context, PaintPhase phase) const
auto offset = context.rounded_device_pixels(1);
text_rect.translate_by(offset, offset);
}
context.painter().draw_text(text_rect.to_type<int>(), static_cast<HTML::HTMLInputElement const&>(dom_node).value(), layout_box().font(), Gfx::TextAlignment::Center, computed_values().color());
context.painter().draw_text(
text_rect.to_type<int>(),
static_cast<HTML::HTMLInputElement const&>(dom_node).value(),
FontCache::the().scaled_font(layout_box().font(), context.device_pixels_per_css_pixel()),
Gfx::TextAlignment::Center,
computed_values().color());
}
}