[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.
This commit is contained in:
Romain Goyet
2018-10-10 22:28:38 +02:00
committed by LeaNumworks
parent fd136f71e7
commit 1dd1e6ca8d

View File

@@ -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++;