mirror of
https://gitlab.com/MisterBiggs/bdfparse.git
synced 2025-06-15 22:16:41 +00:00
added more chars to word function
This commit is contained in:
parent
295c9207a5
commit
217ff46bd7
22
bdfparse.py
22
bdfparse.py
@ -7,6 +7,7 @@ class Font:
|
||||
self.chars = self.parse_chars(bdfFile)
|
||||
self.cols = self.properties["FONTBOUNDINGBOX"][0]
|
||||
self.rows = self.properties["FONTBOUNDINGBOX"][1]
|
||||
self.shape = (self.rows, self.cols)
|
||||
|
||||
def parse_properties(self, bdfFile):
|
||||
|
||||
@ -190,9 +191,22 @@ class Font:
|
||||
)
|
||||
|
||||
def word(self, word: str):
|
||||
matrix = self.chars[word[0]]
|
||||
for char in word[1:]:
|
||||
matrix = np.concatenate((matrix, self.chars[char]), axis=1)
|
||||
matrix = np.zeros(self.shape)
|
||||
for char in word:
|
||||
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 :]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user