Change how UiText renders text

Now UiText renders specified rect surface and on this surface blits text.
This commit is contained in:
Michał Czekański 2020-04-05 22:37:37 +02:00
parent 7f624fe56e
commit e73fc03fc4

View File

@ -19,4 +19,8 @@ class UiText(UiElement):
font = pygame.font.Font(None, 12) font = pygame.font.Font(None, 12)
self.font = font 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))