# HG changeset patch
# User Scott Logan <cottsay>
# Date 1398118533 0
# Branch cottsay/font-dir-fix
# Node ID 2a5b8ea1bac354a0dae8dc5f6ccf1ed899946c1f
# Parent 87cde8ec5f0744724878daf9cc7803c08d803631
Handle a non-existent font dir
When IEP is packaged, system fonts are used and the bundled fonts are removed. IEP currently crashes if the font directory is empty.
diff --git a/iep/iepcore/main.py b/iep/iepcore/main.py
--- a/iep/iepcore/main.py
+++ b/iep/iepcore/main.py
@@ -524,12 +524,13 @@
iep.codeeditor.Manager.setDefaultFontFamily('DejaVu Sans Mono')
# Load fonts that are in the fonts directory
- for fname in os.listdir(fontDir):
- if os.path.splitext(fname)[1].lower() in ['.otf', '.ttf']:
- try:
- db.addApplicationFont( os.path.join(fontDir, fname) )
- except Exception as err:
- print('Could not load font %s: %s' % (fname, str(err)))
+ if os.path.isdir(fontDir):
+ for fname in os.listdir(fontDir):
+ if os.path.splitext(fname)[1].lower() in ['.otf', '.ttf']:
+ try:
+ db.addApplicationFont( os.path.join(fontDir, fname) )
+ except Exception as err:
+ print('Could not load font %s: %s' % (fname, str(err)))
class _CallbackEventHandler(QtCore.QObject):