Skip to content

Commit

Permalink
Fix Monospace font lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov committed Feb 15, 2021
1 parent 31cc2ad commit 852b5e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qrtranslations/fr/qrutils_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
<context>
<name>qReal::ui::ConsoleDock</name>
<message>
<location filename="../../qrutils/widgets/consoleDock.cpp" line="+50"/>
<location filename="../../qrutils/widgets/consoleDock.cpp" line="+54"/>
<source>Reset shell</source>
<translation type="unfinished"></translation>
</message>
Expand Down
2 changes: 1 addition & 1 deletion qrtranslations/ru/qrutils_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@
<context>
<name>qReal::ui::ConsoleDock</name>
<message>
<location filename="../../qrutils/widgets/consoleDock.cpp" line="+50"/>
<location filename="../../qrutils/widgets/consoleDock.cpp" line="+54"/>
<source>Reset shell</source>
<translation>Очистить консоль</translation>
</message>
Expand Down
8 changes: 6 additions & 2 deletions qrutils/widgets/consoleDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ConsoleDock::ConsoleDock(const QString &title, QWidget *parent)
: QDockWidget(title, parent)
, mOutput(new QPlainTextEdit(this))
{
QFont font("Monospace");
QFont font("");
font.setStyleHint(QFont::Monospace);
bool ok;
auto size = qReal::SettingsManager::value("CustomDockTextSize").toInt(&ok);
Expand All @@ -40,7 +40,11 @@ ConsoleDock::ConsoleDock(const QString &title, QWidget *parent)

mOutput->setFont(font);
if (!QFontInfo(mOutput->font()).fixedPitch()) {
QLOG_ERROR() << "Not monospaced font was choosen " << font.toString();
const auto &font1 = mOutput->font();
font.setStyleHint(QFont::TypeWriter);
mOutput->setFont(font);
const auto &font2 = mOutput->font();
QLOG_ERROR() << "Not monospaced font was choosen (" << font1 << "), trying to fallback to" << font2;
}
setWidget(mOutput);
mOutput->setReadOnly(false);
Expand Down

0 comments on commit 852b5e2

Please sign in to comment.