Skip to content

Ignore COMMENT lines no matter how many there are #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions adafruit_bitmap_font/bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down