From 1999b66f3866d9119268d8ad6729de0d938872e5 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Tue, 31 Aug 2021 19:18:53 +0000 Subject: [PATCH] LibGfx: Intersect the bounding box with the main rect in draw_text Without this, the bounding rect for the text as generated by TextLayout can go beyond the bounds of the user-supplied drawing rect and cause the text to overlap because of the line_rect.intersect(rect) a few lines below. --- Userland/Libraries/LibGfx/Painter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 69b19edcae..64f0100786 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1471,6 +1471,8 @@ void Painter::do_draw_text(IntRect const& rect, Utf8View const& text, Font const VERIFY_NOT_REACHED(); } + bounding_rect.intersect(rect); + for (size_t i = 0; i < lines.size(); ++i) { auto line = Utf8View { lines[i] };