From 1dd1e6ca8da318109f2372cd2577e696c6221931 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 10 Oct 2018 22:28:38 +0200 Subject: [PATCH] [kandinsky] Handle drawing clipped text Text can be drawn in a rect that cannot contain the whole character. Luckily, we have fillRectWithPixels handy to handle such cases. --- kandinsky/src/context_text.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kandinsky/src/context_text.cpp b/kandinsky/src/context_text.cpp index 4d3660de1..8d401d773 100644 --- a/kandinsky/src/context_text.cpp +++ b/kandinsky/src/context_text.cpp @@ -22,9 +22,11 @@ KDPoint KDContext::drawString(const char * text, KDPoint p, const KDFont * font, } else { // Fetch and draw glyph for current char font->fetchGlyphForChar(*text, &palette, glyph); - KDRect absoluteRect = absoluteFillRect(KDRect(position, glyphSize.width(), glyphSize.height())); - pushRect(absoluteRect, glyph); - + fillRectWithPixels( + KDRect(position, glyphSize.width(), glyphSize.height()), + glyph, + glyph // It's OK to trash the content of glyph since we'll re-fetch it for the next char anyway + ); position = position.translatedBy(KDPoint(glyphSize.width(), 0)); } text++;