File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 1- import pkg_resources
21import os .path
2+ from glob import glob
33from PIL import ImageFont
44
55def available ():
66 """
77 Returns list of available font names.
88 """
9- names = []
10- for f in pkg_resources .resource_listdir ('ev3dev.fonts' , '' ):
11- name , ext = os .path .splitext (os .path .basename (f ))
12- if ext == '.pil' :
13- names .append (name )
9+ font_dir = os .path .dirname (__file__ )
10+ names = [os .path .basename (os .path .splitext (f )[0 ])
11+ for f in glob (os .path .join (font_dir , '*.pil' ))]
1412 return sorted (names )
1513
1614def load (name ):
@@ -20,8 +18,9 @@ def load(name):
2018 class.
2119 """
2220 try :
23- pil_file = pkg_resources .resource_filename ('ev3dev.fonts' , '{}.pil' .format (name ))
24- pbm_file = pkg_resources .resource_filename ('ev3dev.fonts' , '{}.pbm' .format (name ))
21+ font_dir = os .path .dirname (__file__ )
22+ pil_file = os .path .join (font_dir , '{}.pil' .format (name ))
23+ pbm_file = os .path .join (font_dir , '{}.pbm' .format (name ))
2524 return ImageFont .load (pil_file )
2625 except FileNotFoundError :
2726 raise Exception ('Failed to load font "{}". ' .format (name ) +
You can’t perform that action at this time.
0 commit comments