X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Ftext.py;h=53030c55b8ad730c4a7725f07dc1bf9c5dcf1f52;hb=847d271607652c00e62298a37987aae452719b61;hp=239e10a621b2a74bf9af8a1ad2320582a9308a09;hpb=0b4f46ac5262aed61cf3aeb994a1b55fa7823c7c;p=naja.git diff --git a/naja/widgets/text.py b/naja/widgets/text.py index 239e10a..53030c5 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -1,6 +1,9 @@ +import pygame + from naja.constants import FONT, FONT_SIZE from naja.widgets.base import Widget from naja.resources import resources +from naja.utils import convert_colour class TextWidget(Widget): @@ -10,14 +13,16 @@ class TextWidget(Widget): self.text = text self.fontname = fontname or FONT - self.fontsize = fontsize or FONT_SIZE - self.colour = colour or (0, 0, 0) + self.fontsize = (fontsize or FONT_SIZE) / 2 + self.colour = convert_colour(colour or (0, 0, 0)) - def _prepare(self): + def prepare(self): self.font = resources.get_font(self.fontname, self.fontsize) - self.surface = self.font.render(self.text, True, self.colour) + text = self.font.render(self.text, True, self.colour) + text_rect = text.get_rect() + self.surface = pygame.transform.scale(text, (text_rect.width * 2, + text_rect.height * 2)) self.size = self.surface.get_rect().size def draw(self, surface): - self.prepare() surface.blit(self.surface, self.rect)