diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-09 19:51:14 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-09 19:51:14 +0200 |
commit | d31ddf9aaa899d8cb8a3bdfcadcb2bc781cae640 (patch) | |
tree | 49339912ffcd32372e369fd35cd6c5f0c555e060 /Libraries/LibDraw | |
parent | a7200614237a41d97afb13e4200029f3ec108d65 (diff) | |
download | serenity-d31ddf9aaa899d8cb8a3bdfcadcb2bc781cae640.zip |
Painter: Fix off-by-one in bounding rects for right-aligned text
Another instance of "Rect::right() is the last pixel *inside* the rect,
not the first pixel outside the rect" messing me up.
Diffstat (limited to 'Libraries/LibDraw')
-rw-r--r-- | Libraries/LibDraw/Painter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Libraries/LibDraw/Painter.cpp b/Libraries/LibDraw/Painter.cpp index cb2ca25598..c043f5bb41 100644 --- a/Libraries/LibDraw/Painter.cpp +++ b/Libraries/LibDraw/Painter.cpp @@ -653,7 +653,7 @@ void Painter::draw_text(const Rect& rect, const StringView& text, const Font& fo } else if (alignment == TextAlignment::CenterLeft) { bounding_rect.set_location({ rect.x(), rect.center().y() - (bounding_rect.height() / 2) }); } else if (alignment == TextAlignment::CenterRight) { - bounding_rect.set_location({ rect.right() - bounding_rect.width(), rect.center().y() - (bounding_rect.height() / 2) }); + bounding_rect.set_location({ (rect.right() + 1) - bounding_rect.width(), rect.center().y() - (bounding_rect.height() / 2) }); } else if (alignment == TextAlignment::Center) { bounding_rect.center_within(rect); } else { |