1
0
mirror of https://gitlab.com/MisterBiggs/bdfparse.git synced 2025-06-16 06:26:39 +00:00

added more chars to word function

This commit is contained in:
Anson 2019-07-16 21:07:14 -07:00
parent 295c9207a5
commit 217ff46bd7

View File

@ -7,6 +7,7 @@ class Font:
self.chars = self.parse_chars(bdfFile) self.chars = self.parse_chars(bdfFile)
self.cols = self.properties["FONTBOUNDINGBOX"][0] self.cols = self.properties["FONTBOUNDINGBOX"][0]
self.rows = self.properties["FONTBOUNDINGBOX"][1] self.rows = self.properties["FONTBOUNDINGBOX"][1]
self.shape = (self.rows, self.cols)
def parse_properties(self, bdfFile): def parse_properties(self, bdfFile):
@ -190,9 +191,22 @@ class Font:
) )
def word(self, word: str): def word(self, word: str):
matrix = self.chars[word[0]] matrix = np.zeros(self.shape)
for char in word[1:]: for char in word:
matrix = np.concatenate((matrix, self.chars[char]), axis=1) if char is " ":
arr = np.zeros(self.shape)
elif char is "!":
arr = self.chars["exclam"]
elif char is "%":
arr = self.chars["percent"]
elif char is ",":
arr = self.chars["comma"]
elif char is ".":
arr = self.chars["period"]
else:
arr = self.chars[char]
return matrix matrix = np.concatenate((matrix, arr), axis=1)
return matrix[:, self.cols :]