File tree 1 file changed +11
-11
lines changed
1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -33,19 +33,19 @@ def load_font(filename, bitmap=None):
33
33
import displayio
34
34
35
35
bitmap = displayio .Bitmap
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
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
40
40
41
- return bdf .BDF (font_file , bitmap )
42
- if filename .endswith ("pcf" ) and first_four == b"\x01 fcp" :
43
- from . import pcf
41
+ return bdf .BDF (font_file , bitmap )
42
+ if filename .endswith ("pcf" ) and first_four == b"\x01 fcp" :
43
+ from . import pcf
44
44
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
48
48
49
- return ttf .TTF (font_file , bitmap )
49
+ return ttf .TTF (font_file , bitmap )
50
50
51
51
raise ValueError ("Unknown magic number %r" % first_four )
You can’t perform that action at this time.
0 commit comments