From: Stefano Rivera Date: Sun, 11 May 2014 16:23:27 +0000 (+0200) Subject: Blocky text (4 pixels per pixel) X-Git-Tag: 0.1~413^2~1 X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=commitdiff_plain;h=058c8eba9d37a194888974b1545a18325d74f7f1 Blocky text (4 pixels per pixel) --- diff --git a/naja/scenes/menu.py b/naja/scenes/menu.py index 822c87a..a13abcf 100644 --- a/naja/scenes/menu.py +++ b/naja/scenes/menu.py @@ -13,7 +13,7 @@ class MenuScene(Scene): def __init__(self): super(MenuScene, self).__init__() - self.widgets.append(TextWidget((10, 10), 'Haai', + self.widgets.append(TextWidget((10, 10), 'Haai', fontsize=32, colour=(255, 255, 255))) def handle_event(self, ev): diff --git a/naja/widgets/text.py b/naja/widgets/text.py index 39178ed..12df393 100644 --- a/naja/widgets/text.py +++ b/naja/widgets/text.py @@ -1,3 +1,5 @@ +import pygame + from naja.constants import FONT, FONT_SIZE from naja.widgets.base import Widget from naja.resources import resources @@ -10,12 +12,15 @@ class TextWidget(Widget): self.text = text self.fontname = fontname or FONT - self.fontsize = fontsize or FONT_SIZE + self.fontsize = (fontsize or FONT_SIZE) / 2 self.colour = colour or (0, 0, 0) 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):