Skip to content

Commit

Permalink
Add a setting for monospace fonts
Browse files Browse the repository at this point in the history
Applications like terminals need a fixed-width font, otherwise they will
fallback to the system font which is not appropriate.

Closes: #7
  • Loading branch information
plfiorini committed Apr 28, 2016
1 parent 3141059 commit cd41612
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions data/settings/org.hawaiios.desktop.interface.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@
Font size for applications.
</description>
</key>
<key name="monospace-font-name" type="s">
<default>'Droid Sans Mono'</default>
<summary>Monospace Font Name</summary>
<description>
Name of monospaced (fixed-width) font for use in locations
like terminals.
</description>
</key>
<key name="monospace-font-size" type="i">
<default>11</default>
<summary>Monospace Font Size</summary>
<description>
Size of monospaced (fixed-width) font for use in locations
like terminals.
</description>
</key>
<key name="small-font-name" type="s">
<default>'Noto Sans'</default>
<summary>Small Font Family</summary>
Expand Down
10 changes: 10 additions & 0 deletions platformtheme/hawaiitheme_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// Default fonts
static const char defaultSystemFontName[] = "Droid Sans";
static int defaultSystemFontSize = 11;
static const char defaultMonospaceFontName[] = "Droid Sans Mono";
static int defaultMonospaceFontSize = 11;

HawaiiThemePrivate::HawaiiThemePrivate()
{
Expand Down Expand Up @@ -76,6 +78,8 @@ void HawaiiThemePrivate::refresh()
// Fonts
QString fontFamily = settings->value(QStringLiteral("fontName")).toString();
int fontSize = settings->value(QStringLiteral("fontSize")).toInt();
QString monospaceFontFamily = settings->value(QStringLiteral("monospaceFontName")).toString();
int monospaceFontSize = settings->value(QStringLiteral("monospaceFontSize")).toInt();
QString smallFontFamily = settings->value(QStringLiteral("smallFontName")).toString();
int smallFontSize = settings->value(QStringLiteral("smallFontSize")).toInt();
QString miniFontFamily = settings->value(QStringLiteral("miniFontName")).toString();
Expand All @@ -87,6 +91,12 @@ void HawaiiThemePrivate::refresh()
else
resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize);

// Monospace font
if (QFont *monospaceFont = readFont(monospaceFontFamily, monospaceFontSize))
resources.fonts[QPlatformTheme::FixedFont] = monospaceFont;
else
resources.fonts[QPlatformTheme::FixedFont] = new QFont(QLatin1String(defaultMonospaceFontName), defaultMonospaceFontSize);

// Small font
if (QFont *smallFont = readFont(smallFontFamily, smallFontSize))
resources.fonts[QPlatformTheme::SmallFont] = smallFont;
Expand Down

0 comments on commit cd41612

Please sign in to comment.