diff options
author | VayuDev <vayudev@protonmail.com> | 2023-01-05 19:48:39 +0100 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-01-05 15:47:40 -0500 |
commit | fab8ef3dfcd56c8e4d870f870a82765e2b36e510 (patch) | |
tree | 52b9fbeee95ee8a0cec8201d7659cb40b6e7979b /Userland/Libraries | |
parent | 93737a4b00ce3d4731b53d74a1a1a581f5277c34 (diff) | |
download | serenity-fab8ef3dfcd56c8e4d870f870a82765e2b36e510.zip |
LibWeb: Pass FloatRect to Painter::draw_text in fill_text
Don't round float values to int values in
CanvasRenderingContext2D::fill_text when passing them to
Painter::draw_text.
This also fixes a fixme.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 82bdcde6f5..39ac26198f 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -204,11 +204,10 @@ void CanvasRenderingContext2D::fill_text(DeprecatedString const& text, float x, auto& drawing_state = this->drawing_state(); - // FIXME: painter only supports integer rects for text right now, so this effectively chops off any fractional position - auto text_rect = Gfx::IntRect(x, y, max_width.has_value() ? static_cast<float>(max_width.value()) : painter->font().width(text), painter->font().pixel_size()); + auto text_rect = Gfx::FloatRect(x, y, max_width.has_value() ? static_cast<float>(max_width.value()) : painter->font().width(text), painter->font().pixel_size()); auto transformed_rect = drawing_state.transform.map(text_rect); painter->draw_text(transformed_rect, text, Gfx::TextAlignment::TopLeft, drawing_state.fill_style); - did_draw(transformed_rect.to_type<float>()); + did_draw(transformed_rect); } void CanvasRenderingContext2D::stroke_text(DeprecatedString const& text, float x, float y, Optional<double> max_width) |