Skip to content

Commit

Permalink
GUI: Allow font style customization with :Guifont
Browse files Browse the repository at this point in the history
  • Loading branch information
jpleau authored and equalsraf committed Apr 4, 2016
1 parent 3189c95 commit 04c73f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ bool Shell::setGuiFont(const QString& fdesc)
}

int pointSize = font().pointSize();
int weight = -1;
bool italic = false;
foreach(QString attr, attrs) {
if (attr.size() >= 2 && attr[0] == 'h') {
bool ok = false;
Expand All @@ -90,9 +92,13 @@ bool Shell::setGuiFont(const QString& fdesc)
return false;
}
pointSize = height;
} else if (attr == "b") {
weight = QFont::Bold;
} else if (attr == "i") {
italic = true;
}
}
setShellFont(attrs.at(0), pointSize);
setShellFont(attrs.at(0), pointSize, weight, italic);

if (m_attached) {
resizeNeovim(size());
Expand Down
6 changes: 2 additions & 4 deletions src/gui/shellwidget/shellwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ void ShellWidget::setDefaultFont()
#endif
}

bool ShellWidget::setShellFont(const QString& family, int ptSize)
bool ShellWidget::setShellFont(const QString& family, int ptSize, int weight, bool italic)
{
QFont f;
QFont f(family, ptSize, weight, italic);
f.setStyleHint(QFont::TypeWriter, QFont::StyleStrategy(QFont::PreferDefault | QFont::ForceIntegerMetrics));
f.setFamily(family);
f.setFixedPitch(true);
f.setKerning(false);
f.setPointSize(ptSize);

QFontInfo fi(f);
if (fi.family().compare(f.family(), Qt::CaseInsensitive) != 0 &&
Expand Down
2 changes: 1 addition & 1 deletion src/gui/shellwidget/shellwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ShellWidget: public QWidget
Q_PROPERTY(QSize cellSize READ cellSize)
public:
ShellWidget(QWidget *parent=0);
bool setShellFont(const QString& family, int ptSize);
bool setShellFont(const QString& family, int ptSize, int weight = -1, bool italic = false);

QColor background() const;
QColor foreground() const;
Expand Down

0 comments on commit 04c73f1

Please sign in to comment.