From 936c6c8a88dabfb952b3080d3120d9b76ecdfb80 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 29 Nov 2023 11:15:48 +0100 Subject: [PATCH] Use monospace font from stylesheet using a custom property --- usd_qtpy/layer_diff.py | 2 +- usd_qtpy/layer_editor.py | 2 +- usd_qtpy/style/style.css | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/usd_qtpy/layer_diff.py b/usd_qtpy/layer_diff.py index 6e4db18..36c3af6 100644 --- a/usd_qtpy/layer_diff.py +++ b/usd_qtpy/layer_diff.py @@ -60,7 +60,7 @@ def __init__(self, text_edit = QtWidgets.QTextEdit() # Force monospace font for readability - text_edit.setStyleSheet('* { font-family: "Courier"; }') + text_edit.setProperty("font-style", "monospace") text_edit.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) highlighter = DifflibSyntaxHighlighter(text_edit) text_edit.setPlaceholderText("Layers match - no difference detected.") diff --git a/usd_qtpy/layer_editor.py b/usd_qtpy/layer_editor.py index 244e3ba..0e6e15a 100644 --- a/usd_qtpy/layer_editor.py +++ b/usd_qtpy/layer_editor.py @@ -603,7 +603,7 @@ def on_view_context_menu(self, point): def show_layer_as_text(): text_edit = QtWidgets.QTextEdit(parent=self) - text_edit.setStyleSheet('* { font-family: "Courier"; }') + text_edit.setProperty("font-style", "monospace") text_edit.setPlainText(layer.ExportToString()) text_edit.setWindowTitle(layer.identifier) text_edit.setWindowFlags(QtCore.Qt.Dialog) diff --git a/usd_qtpy/style/style.css b/usd_qtpy/style/style.css index 479ec4c..fe0dffe 100644 --- a/usd_qtpy/style/style.css +++ b/usd_qtpy/style/style.css @@ -25,6 +25,10 @@ Enabled vs Disabled logic in most of stylesheets outline: none; } +*[font-style="monospace"] { + font-family: "Noto Sans Mono"; +} + QWidget { color: {color:font}; background: {color:bg};