Change default font in code editors (#2985)

* Change default font in code editors

* Fall back to system font
This commit is contained in:
Abdo 2024-02-02 10:03:29 +03:00 committed by GitHub
parent 54b1cc5689
commit 312d396505
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -1543,6 +1543,8 @@ class ConfigEditor(QDialog):
tooltip(tr.addons_restored_defaults(), parent=self)
def setupFonts(self) -> None:
font_mono = QFont("Consolas")
if not font_mono.exactMatch():
font_mono = QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont)
font_mono.setPointSize(font_mono.pointSize() + 1)
self.form.editor.setFont(font_mono)

View file

@ -267,7 +267,10 @@ class CardLayout(QDialog):
self.current_editor_index = 0
editor.setAcceptRichText(False)
editor.setFont(QFont("Courier"))
font = QFont("Consolas")
if not font.exactMatch():
font = QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont)
editor.setFont(font)
tab_width = self.fontMetrics().horizontalAdvance(" " * 4)
editor.setTabStopDistance(tab_width)