From ff9fe32f4968d87dabb06a4890b24bddc1caf932 Mon Sep 17 00:00:00 2001 From: Scott Lyons Date: Wed, 1 Sep 2021 13:39:00 -0700 Subject: [PATCH] Ignore COMMENT lines no matter how many there are --- adafruit_bitmap_font/bdf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adafruit_bitmap_font/bdf.py b/adafruit_bitmap_font/bdf.py index e15ab0c..e5ccfbb 100644 --- a/adafruit_bitmap_font/bdf.py +++ b/adafruit_bitmap_font/bdf.py @@ -89,12 +89,16 @@ def _verify_bounding_box(self): file to verify the value or raise an exception in case is not found """ self.file.seek(0) + line = self.file.readline() + line = str(line, "utf-8") # Normally information about the FONT is in the first four lines. # Exception is when font file have a comment. Comments are three lines # 10 lines is a safe bet for _ in range(11): - line = self.file.readline() - line = str(line, "utf-8") + # Let's just ignore comment lines no matter how many there are + while line.startswith("COMMENT"): + line = self.file.readline() + line = str(line, "utf-8") if line.startswith("FONTBOUNDINGBOX "): _, x, y, x_offset, y_offset = line.split() self._boundingbox = (int(x), int(y), int(x_offset), int(y_offset))