-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathFont.py
33 lines (29 loc) · 940 Bytes
/
Font.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from classes.Spritesheet import Spritesheet
import pygame
class Font(Spritesheet):
def __init__(self, filePath, size):
Spritesheet.__init__(self, filename=filePath)
self.chars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
self.charSprites = self.loadFont()
def loadFont(self):
font = {}
row = 0
charAt = 0
for char in self.chars:
if charAt == 16:
charAt = 0
row += 1
font.update(
{
char: self.image_at(
charAt,
row,
2,
colorkey=pygame.color.Color(0, 0, 0),
xTileSize=8,
yTileSize=8
)
}
)
charAt += 1
return font