From e73fc03fc4c141ceb9c0f17869a0773f78d24117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 5 Apr 2020 22:37:37 +0200 Subject: [PATCH] Change how UiText renders text Now UiText renders specified rect surface and on this surface blits text. --- src/ui/UiText.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/UiText.py b/src/ui/UiText.py index babd7ae..a6beb6a 100644 --- a/src/ui/UiText.py +++ b/src/ui/UiText.py @@ -19,4 +19,8 @@ class UiText(UiElement): font = pygame.font.Font(None, 12) self.font = font - self.image = font.render(text, antialias, textColor, backgroundColor) + self.image = pygame.Surface((rect.w, rect.h)) + if backgroundColor is not None: + self.image.fill(backgroundColor) + wordImage = self.font.render(text, antialias, textColor) + self.image.blit(wordImage, (0, 0))