Krita Source Code Documentation
Loading...
Searching...
No Matches
KisUiFont Namespace Reference

Functions

QFont dockFont ()
 Gets a font with a smallish font size for dock widgets to use.
 
QFont normalFont ()
 Gets a font for normal UI widgets to use.
 
static QFont systemDefaultUiFont ()
 Gets the system default UI font.
 
static boost::optional< QFont > userCfgUiFont ()
 Returns the font the user has configured.
 

Variables

static const QString customFontSizeCfgName = QStringLiteral("custom_font_size")
 
static const QString customSystemFontCfgName = QStringLiteral("custom_system_font")
 
static const QString useCustomSystemFontCfgName = QStringLiteral("use_custom_system_font")
 

Function Documentation

◆ dockFont()

KRITAUI_EXPORT QFont KisUiFont::dockFont ( )

Gets a font with a smallish font size for dock widgets to use.

Returns
the small font.

Definition at line 98 of file KisUiFont.cpp.

99{
100 QFont font = normalFont();
101 font.setPointSizeF(font.pointSizeF() * 0.9);
102 return font;
103}
QFont normalFont()
Gets a font for normal UI widgets to use.
Definition KisUiFont.cpp:81

References normalFont().

◆ normalFont()

KRITAUI_EXPORT QFont KisUiFont::normalFont ( )

Gets a font for normal UI widgets to use.

Returns
the UI font.

Definition at line 81 of file KisUiFont.cpp.

82{
83 QFont font;
84 if (boost::optional<QFont> userFont = userCfgUiFont()) {
85 font = *userFont;
86 } else {
87 font = systemDefaultUiFont();
88 }
89#ifdef Q_OS_WIN
90 // XXX: Forces Qt to use full hinting for UI text, otherwise the default
91 // will cause Qt to do vertical hinting only when High-DPI is active,
92 // which makes some UI text extremely blurry on CJK systems.
93 font.setHintingPreference(QFont::PreferFullHinting);
94#endif
95 return font;
96}
static boost::optional< QFont > userCfgUiFont()
Returns the font the user has configured.
Definition KisUiFont.cpp:63

References systemDefaultUiFont(), and userCfgUiFont().

◆ systemDefaultUiFont()

QFont KisUiFont::systemDefaultUiFont ( )
static

Gets the system default UI font.

Returns
the system default UI font.

Definition at line 49 of file KisUiFont.cpp.

50{
51#if defined(Q_OS_WIN) && QT_VERSION < 0x060000
52 return windowsSystemUiFont();
53#else
54 QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
55 // On Android, font size may be in pixels, but we expect it to be in points
56 if (font.pointSizeF() == -1) {
57 font.setPointSizeF(font.pixelSize());
58 }
59 return font;
60#endif
61}

◆ userCfgUiFont()

boost::optional< QFont > KisUiFont::userCfgUiFont ( )
static

Returns the font the user has configured.

Returns
the user font if it has been set, otherwise boost::none.

Definition at line 63 of file KisUiFont.cpp.

64{
65 KisConfig cfg(true);
66 if (cfg.readEntry<bool>(useCustomSystemFontCfgName, false)) {
67 QString fontName = cfg.readEntry<QString>(customSystemFontCfgName, QString());
68 if (fontName.isEmpty()) {
69 return boost::none;
70 }
71 int fontSize = cfg.readEntry<int>(customFontSizeCfgName, -1);
72 if (fontSize <= 6) {
73 fontSize = systemDefaultUiFont().pointSize();
74 }
75 return QFont(fontName, fontSize);
76 } else {
77 return boost::none;
78 }
79}
static const QString customSystemFontCfgName
Definition KisUiFont.cpp:30

References customFontSizeCfgName, customSystemFontCfgName, KisConfig::readEntry(), systemDefaultUiFont(), and useCustomSystemFontCfgName.

Variable Documentation

◆ customFontSizeCfgName

const QString KisUiFont::customFontSizeCfgName = QStringLiteral("custom_font_size")
static

Definition at line 31 of file KisUiFont.cpp.

◆ customSystemFontCfgName

const QString KisUiFont::customSystemFontCfgName = QStringLiteral("custom_system_font")
static

Definition at line 30 of file KisUiFont.cpp.

◆ useCustomSystemFontCfgName

const QString KisUiFont::useCustomSystemFontCfgName = QStringLiteral("use_custom_system_font")
static

Definition at line 29 of file KisUiFont.cpp.