Skip to content

Commit

Permalink
Use monospace font from stylesheet using a custom property
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy committed Nov 29, 2023
1 parent 08f8e1a commit 936c6c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion usd_qtpy/layer_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion usd_qtpy/layer_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions usd_qtpy/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 936c6c8

Please sign in to comment.