Skip to content

Commit 7b80b05

Browse files
committed
changing char_width_pixels to be using fixedFont()
Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com>
1 parent 1c3aafb commit 7b80b05

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/osltoy/codeeditor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename)
5353
setLineWrapMode(QPlainTextEdit::NoWrap);
5454
document()->setDefaultFont(fixedFont());
5555

56-
setTabStopDistance(4 * char_width_pixels());
57-
5856
lineNumberArea = new LineNumberArea(this);
5957

6058
connect(this, SIGNAL(blockCountChanged(int)), this,
@@ -66,6 +64,7 @@ CodeEditor::CodeEditor(QWidget* parent, const std::string& filename)
6664

6765
updateLineNumberAreaWidth(0);
6866
highlightCurrentLine();
67+
setTabStopDistance(4 * char_width_pixels());
6968
}
7069

7170

@@ -100,11 +99,12 @@ CodeEditor::text_string() const
10099
int
101100
CodeEditor::char_width_pixels() const
102101
{
103-
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
104-
return fontMetrics().horizontalAdvance(QLatin1Char('M'));
102+
QFontMetrics metrics(fixedFont());
103+
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
104+
return metrics.horizontalAdvance(QLatin1Char('M'));
105105
#else
106106
// QFontMetric.width() deprecated from 5.11, marked as such in 5.13
107-
return fontMetrics().width(QLatin1Char('M'));
107+
return metrics.width(QLatin1Char('M'));
108108
#endif
109109
}
110110

0 commit comments

Comments
 (0)