From e8fb61cf43dfe3913f239d91f762f150f893b0fd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 23 Jan 2016 16:00:46 -0800 Subject: [PATCH] Font: Fix clipping when x/y aren't 0. The final X2/Y2 are relative to the glyph at x,y. --- Core/Font/PGF.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Font/PGF.cpp b/Core/Font/PGF.cpp index 7d52777a8b..45b9998990 100644 --- a/Core/Font/PGF.cpp +++ b/Core/Font/PGF.cpp @@ -637,8 +637,8 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW int renderX1 = std::max(clipX, x) - x; int renderY1 = std::max(clipY, y) - y; // We can render up to frac beyond the glyph w/h, so add 1px if necessary. - int renderX2 = std::min(clipX + clipWidth, glyph.w + (xFrac > 0 ? 1 : 0)); - int renderY2 = std::min(clipY + clipHeight, glyph.h + (yFrac > 0 ? 1 : 0)); + int renderX2 = std::min(clipX + clipWidth - x, glyph.w + (xFrac > 0 ? 1 : 0)); + int renderY2 = std::min(clipY + clipHeight - y, glyph.h + (yFrac > 0 ? 1 : 0)); if (xFrac == 0 && yFrac == 0) { for (int yy = renderY1; yy < renderY2; ++yy) {