Add font loader and DejaVu sans font
[tabakrolletjie.git] / tabakrolletjie / loader.py
index b2ff5270cb8b315203c86594c3e5194fc889fe43..252960b42b90e9850206dc215d3a8a8e551c24b4 100644 (file)
@@ -4,6 +4,7 @@ import json
 import os
 
 import pygame.image
+import pygame.font
 import pygame.display
 
 from .constants import DEBUG
@@ -43,6 +44,14 @@ class Loader(object):
             self._cache[fn] = img
         return img
 
+    def load_font(self, *parts, **kwargs):
+        """Return a pygame font of the given size"""
+        size = kwargs.get('size', 12)
+        fn = self.full_path("fonts", *parts)
+        font = pygame.font.Font(fn, size)
+        # Do we need to cache this?
+        return font
+
 
 _DATA_PREFIX = os.path.abspath(
     os.path.join(os.path.dirname(__file__), "..", "data"))