Skip to content

Commit 4871e1f

Browse files
committed
Don't draw filled rectangles outside of text image
1 parent 08e63fe commit 4871e1f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ft2font.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1,
146146
{
147147
x0 = std::min(x0, m_width);
148148
y0 = std::min(y0, m_height);
149-
x1 = std::min(x1, m_width);
150-
y1 = std::min(y1, m_height);
149+
x1 = std::min(x1 + 1, m_width);
150+
y1 = std::min(y1 + 1, m_height);
151151

152-
for (size_t j = y0; j < y1 + 1; j++) {
153-
for (size_t i = x0; i < x1 + 1; i++) {
152+
for (size_t j = y0; j < y1; j++) {
153+
for (size_t i = x0; i < x1; i++) {
154154
m_buffer[i + j * m_width] = 255;
155155
}
156156
}

0 commit comments

Comments
 (0)