diff --git a/bdfparse.py b/bdfparse.py index 46b9126..0d92899 100644 --- a/bdfparse.py +++ b/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 :]