Skip to content

Commit cf5bf45

Browse files
added a fix for the index error while fetching the font
1 parent 1029085 commit cf5bf45

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

‎src/ui/main_window.py‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ def __init__(self,applications,*args, **kwargs):
3131
self.config_manager()
3232

3333
#font
34-
font_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','JetBrainsMonoNerdFont-Bold.ttf'))
35-
font_id = QFontDatabase.addApplicationFont(font_path)
36-
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
37-
font = QFont(font_family, 10)
38-
self.font = font
34+
try:
35+
font_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','JetBrainsMonoNerdFont-Bold.ttf'))
36+
font_id = QFontDatabase.addApplicationFont(font_path)
37+
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
38+
font = QFont(font_family, 10)
39+
self.font = font
40+
except IndexError:
41+
font_path = "/usr/share/fonts/TTF/JetBrainsMonoNerdFont-Bold.ttf"
42+
font_id = QFontDatabase.addApplicationFont(font_path)
43+
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
44+
font = QFont(font_family, 10)
45+
self.font = font
46+
3947

4048
# output area for the shell output
4149
self.command_display= QTextEdit()

‎src/ui/widget.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@ def __init__(self,name:str,app_info: dict):
2323
# self.btn = QPushButton(text = name, icon=QIcon(app_info.get('icon')))
2424
self.btn.setFixedHeight(35)
2525

26-
font_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','JetBrainsMonoNerdFont-Bold.ttf'))
27-
font_id = QFontDatabase.addApplicationFont(font_path)
28-
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
26+
try:
27+
font_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','JetBrainsMonoNerdFont-Bold.ttf'))
28+
font_id = QFontDatabase.addApplicationFont(font_path)
29+
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
30+
except IndexError:
31+
font_path = "/usr/share/fonts/TTF/JetBrainsMonoNerdFont-Bold.ttf"
32+
font_id = QFontDatabase.addApplicationFont(font_path)
33+
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
34+
font = QFont(font_family, 10)
35+
self.font = font
36+
37+
2938
font = QFont(font_family, 11)
3039
self.btn.setFont(font)
3140
self.hbox = QHBoxLayout() # a horizontal layout to encapsulate the above

0 commit comments

Comments
 (0)