1616from nxt import DATA_STATE , nxt_path
1717from nxt .nxt_node import INTERNAL_ATTRS
1818from nxt_editor .dockwidgets import syntax
19+ from nxt_editor .constants import FONTS
1920import nxt_editor
2021
2122logger = logging .getLogger (nxt_editor .LOGGER_NAME )
@@ -72,7 +73,7 @@ def __init__(self, title='Code Editor', parent=None, minimum_width=500):
7273 self .details_layout .addLayout (self .name_layout )
7374
7475 self .name_label = LabelEdit (parent = self .details_frame )
75- self .name_label .setFont (QtGui .QFont ("Roboto" , 14 ))
76+ self .name_label .setFont (QtGui .QFont (FONTS . DEFAULT_FAMILY , 14 ))
7677 self .name_label .nameChangeRequested .connect (self .edit_name )
7778 self .name_layout .addWidget (self .name_label , 0 , QtCore .Qt .AlignLeft )
7879
@@ -86,7 +87,7 @@ def __init__(self, title='Code Editor', parent=None, minimum_width=500):
8687 self .name_layout .addWidget (self .name_edit_button , 0 , QtCore .Qt .AlignLeft )
8788
8889 self .path_label = QtWidgets .QLabel (parent = self .details_frame )
89- self .path_label .setFont (QtGui .QFont ("Roboto Mono" , 8 ))
90+ self .path_label .setFont (QtGui .QFont (FONTS . MONOSPACE , 8 ))
9091 self .path_label .setStyleSheet ('color: grey' )
9192 self .details_layout .addWidget (self .path_label )
9293
@@ -600,9 +601,8 @@ def __init__(self, show_line_numbers=True, highlight_current_line=True,
600601 self .setFocusPolicy (QtCore .Qt .ClickFocus )
601602
602603 # font settings
603- self .font_size = 10
604- self .font_family = 'Roboto Mono'
605- self .setFont (QtGui .QFont (self .font_family , self .font_size ))
604+ self .font_size = FONTS .DEFAULT_SIZE
605+ self .setFont (FONTS .monospace_font (self .font_size ))
606606 self .setLineWrapMode (QtWidgets .QPlainTextEdit .NoWrap )
607607
608608 # display settings
@@ -754,7 +754,9 @@ def set_font_size(self, delta=0.0, default=False):
754754 self .font_size = 10
755755 else :
756756 self .font_size += delta
757- self .setFont (QtGui .QFont (self .font_family , self .font_size ))
757+ font = self .font ()
758+ font .setPointSize (self .font_size )
759+ self .setFont (font )
758760
759761 def update_previous_scroll_positions (self ):
760762 self .prev_v_scroll_value = self .verticalScrollBar ().value ()
@@ -1217,7 +1219,6 @@ def __init__(self, editor, color):
12171219 self .editor = editor
12181220 self .editor .blockCountChanged .connect (self .update_width )
12191221 self .editor .updateRequest .connect (self .update_contents )
1220- self .font = QtGui .QFont ()
12211222 self .color = QtGui .QColor (color )
12221223 self .update_width ()
12231224
@@ -1231,7 +1232,7 @@ def paintEvent(self, event):
12311232 changed_lines = []
12321233 # Iterate over all visible text blocks in the document.
12331234 while block .isValid ():
1234- self .font .setBold (False )
1235+ self .font () .setBold (False )
12351236 block_number = block .blockNumber ()
12361237 block_top = self .editor .blockBoundingGeometry (block ).translated (
12371238 self .editor .contentOffset ()).top ()
@@ -1241,7 +1242,7 @@ def paintEvent(self, event):
12411242 # We want the line number for the selected line to be bold.
12421243 painter .setPen (QtGui .QColor (colors .LIGHTER_TEXT ))
12431244 if block_number == self .editor .textCursor ().blockNumber ():
1244- self .font .setBold (True )
1245+ self .font () .setBold (True )
12451246 else :
12461247 painter .setPen (colors .DEFAULT_TEXT )
12471248 # Draw the line number right justified at the position of the line.
@@ -1252,7 +1253,7 @@ def paintEvent(self, event):
12521253 painter .fillRect (paint_rect , colors .UNSAVED )
12531254 painter .setPen (colors .LIGHTEST_TEXT )
12541255 changed_lines .remove (block_number )
1255- painter .setFont (self .font )
1256+ painter .setFont (self .font () )
12561257 text_rect = paint_rect .marginsAdded (QtCore .QMargins (0 , 0 , - 4 , 0 ))
12571258 painter .drawText (text_rect , QtCore .Qt .AlignRight ,
12581259 str (block_number + 1 ))
@@ -1288,8 +1289,8 @@ def update_contents(self, rect, scroll):
12881289
12891290 if rect .contains (self .editor .viewport ().rect ()):
12901291 font_size = self .editor .currentCharFormat ().font ().pointSize ()
1291- self .font .setPointSize (font_size )
1292- self .font .setStyle (QtGui .QFont .StyleNormal )
1292+ self .font () .setPointSize (font_size )
1293+ self .font () .setStyle (QtGui .QFont .StyleNormal )
12931294 self .update_width ()
12941295
12951296
@@ -1310,7 +1311,7 @@ def __init__(self, parent=None):
13101311 def paintEvent (self , event ):
13111312 painter = QtGui .QPainter ()
13121313 painter .begin (self )
1313- painter .setFont (QtGui .QFont ("Roboto" , 14 ))
1314+ painter .setFont (QtGui .QFont (FONTS . MONOSPACE , 14 ))
13141315 font_metrics = QtGui .QFontMetrics (painter .font ())
13151316 painter .setRenderHint (QtGui .QPainter .Antialiasing )
13161317 # actual_display_state
0 commit comments