Skip to content

Commit aeb30d0

Browse files
authored
Merge pull request #52 from FoamyGuy/remove_with_context_usage
remove usage of with context in bitmap_font.py for now
2 parents a3272e2 + aaab827 commit aeb30d0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

adafruit_bitmap_font/bitmap_font.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@
2828

2929
def load_font(filename, bitmap=None):
3030
"""Loads a font file. Returns None if unsupported."""
31-
# pylint: disable=import-outside-toplevel
31+
# pylint: disable=import-outside-toplevel, consider-using-with
3232
if not bitmap:
3333
import displayio
3434

3535
bitmap = displayio.Bitmap
36-
with open(filename, "rb") as font_file:
37-
first_four = font_file.read(4)
38-
if filename.endswith("bdf") and first_four == b"STAR":
39-
from . import bdf
36+
font_file = open(filename, "rb")
37+
first_four = font_file.read(4)
38+
if filename.endswith("bdf") and first_four == b"STAR":
39+
from . import bdf
4040

41-
return bdf.BDF(font_file, bitmap)
42-
if filename.endswith("pcf") and first_four == b"\x01fcp":
43-
from . import pcf
41+
return bdf.BDF(font_file, bitmap)
42+
if filename.endswith("pcf") and first_four == b"\x01fcp":
43+
from . import pcf
4444

45-
return pcf.PCF(font_file, bitmap)
46-
if filename.endswith("ttf") and first_four == b"\x00\x01\x00\x00":
47-
from . import ttf
45+
return pcf.PCF(font_file, bitmap)
46+
if filename.endswith("ttf") and first_four == b"\x00\x01\x00\x00":
47+
from . import ttf
4848

49-
return ttf.TTF(font_file, bitmap)
49+
return ttf.TTF(font_file, bitmap)
5050

5151
raise ValueError("Unknown magic number %r" % first_four)

0 commit comments

Comments
 (0)