Changeset 33:d9b65cf72db4


Ignore:
Timestamp:
Sep 1, 2013, 2:44:04 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
dbfc6178bb8deed87dcc916a0429a1a97fe4bf8a
Message:

Prettier resource loading module

Files:
2 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/widgets/text.py

    r29 r33  
    1 import pygame
    2 
    31from nagslang.constants import FONT, FONT_SIZE
    4 from nagslang.data import filepath
    52from nagslang.widgets.base import Widget
    63from nagslang.utils import convert_colour
     4from nagslang.resources import resources
    75
    86
    97class TextWidget(Widget):
    10     fonts = {}
    11 
    128    def __init__(self, pos, text, size=None, fontname=None, fontsize=None,
    139                 colour=None):
     
    2218
    2319    def prepare(self):
    24         font = (self.fontname, self.fontsize)
    25         if font not in TextWidget.fonts:
    26             fn = filepath('fonts/' + self.fontname)
    27             TextWidget.fonts[font] = pygame.font.Font(fn, self.fontsize)
    28         self.font = TextWidget.fonts[font]
     20        self.font = resources.get_font(self.fontname, self.fontsize)
    2921        self.surface = self.font.render(self.text, True, self.colour)
    3022        self.text_rect = self.surface.get_rect()
Note: See TracChangeset for help on using the changeset viewer.