From 058c8eba9d37a194888974b1545a18325d74f7f1 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 11 May 2014 18:23:27 +0200 Subject: [PATCH] Blocky text (4 pixels per pixel) --- naja/scenes/menu.py | 2 +- naja/widgets/text.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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): -- 2.34.1