File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,25 @@ def __getitem__(self, key):
142142 return self ._fontData [key ]
143143
144144
145+ def _check_if_exists (filename ):
146+ """!
147+ Checks if a file or directory exists. Works on MicroPython and CircuitPython
148+ which do not have os.path functions (as well as Linux which does).
149+ """
150+ try :
151+ os .stat (filename )
152+ return True
153+ except :
154+ return False
155+
145156# handy util
146-
147157def _getFontDir ():
148158
159+ # First check if font directory exists where it is installed when using a frozen SparkFun MicroPython package
160+ # It should exist in "_frozen_data" if the package is frozen
161+ if _check_if_exists ("_frozen_data" + os .sep + "fonts" ):
162+ return "_frozen_data" + os .sep + "fonts"
163+
149164 return __file__ .rsplit (os .sep , 1 )[0 ] + os .sep + "fonts"
150165
151166#-----------------------------------------
You can’t perform that action at this time.
0 commit comments