Skip to content

Commit 04c73f1

Browse files
jpleauequalsraf
authored andcommitted
GUI: Allow font style customization with :Guifont
1 parent 3189c95 commit 04c73f1

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/gui/shell.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ bool Shell::setGuiFont(const QString& fdesc)
8181
}
8282

8383
int pointSize = font().pointSize();
84+
int weight = -1;
85+
bool italic = false;
8486
foreach(QString attr, attrs) {
8587
if (attr.size() >= 2 && attr[0] == 'h') {
8688
bool ok = false;
@@ -90,9 +92,13 @@ bool Shell::setGuiFont(const QString& fdesc)
9092
return false;
9193
}
9294
pointSize = height;
95+
} else if (attr == "b") {
96+
weight = QFont::Bold;
97+
} else if (attr == "i") {
98+
italic = true;
9399
}
94100
}
95-
setShellFont(attrs.at(0), pointSize);
101+
setShellFont(attrs.at(0), pointSize, weight, italic);
96102

97103
if (m_attached) {
98104
resizeNeovim(size());

src/gui/shellwidget/shellwidget.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ void ShellWidget::setDefaultFont()
3434
#endif
3535
}
3636

37-
bool ShellWidget::setShellFont(const QString& family, int ptSize)
37+
bool ShellWidget::setShellFont(const QString& family, int ptSize, int weight, bool italic)
3838
{
39-
QFont f;
39+
QFont f(family, ptSize, weight, italic);
4040
f.setStyleHint(QFont::TypeWriter, QFont::StyleStrategy(QFont::PreferDefault | QFont::ForceIntegerMetrics));
41-
f.setFamily(family);
4241
f.setFixedPitch(true);
4342
f.setKerning(false);
44-
f.setPointSize(ptSize);
4543

4644
QFontInfo fi(f);
4745
if (fi.family().compare(f.family(), Qt::CaseInsensitive) != 0 &&

src/gui/shellwidget/shellwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ShellWidget: public QWidget
1717
Q_PROPERTY(QSize cellSize READ cellSize)
1818
public:
1919
ShellWidget(QWidget *parent=0);
20-
bool setShellFont(const QString& family, int ptSize);
20+
bool setShellFont(const QString& family, int ptSize, int weight = -1, bool italic = false);
2121

2222
QColor background() const;
2323
QColor foreground() const;

0 commit comments

Comments
 (0)