Ignore:
Timestamp:
09/01/13 14:44:04 (8 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Rebase:
64626663363137386262386465656438376463633931366130343239613161393766653462663861
Message:

Prettier resource loading module

File:
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.