Skip to content

Commit fe12f39

Browse files
authored
Merge pull request #26912 from Eism/ui_font_atempt_to_fix_4.5
Attempt to fix #24456: UI font sometimes gets replaced by a symbol font on update
2 parents f902da7 + 30a1772 commit fe12f39

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/framework/ui/internal/uiconfiguration.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ void UiConfiguration::init()
107107
m_windowGeometryChanged.notify();
108108
});
109109

110+
correctUserFontIfNeeded();
111+
110112
initThemes();
111113
}
112114

@@ -138,6 +140,17 @@ void UiConfiguration::initThemes()
138140
updateCurrentTheme();
139141
}
140142

143+
void UiConfiguration::correctUserFontIfNeeded()
144+
{
145+
QString userFontFamily = QString::fromStdString(fontFamily());
146+
if (!QFontDatabase::hasFamily(userFontFamily)) {
147+
std::string fallbackFontFamily = defaultFontFamily();
148+
LOGI() << "The user font " << userFontFamily << " is missing, we will use the fallback font " << fallbackFontFamily;
149+
150+
setFontFamily(fallbackFontFamily);
151+
}
152+
}
153+
141154
void UiConfiguration::updateCurrentTheme()
142155
{
143156
ThemeCode currentCodeKey = currentThemeCodeKey();

src/framework/ui/internal/uiconfiguration.h

+3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class UiConfiguration : public IUiConfiguration, public Injectable, public async
121121

122122
private:
123123
void initThemes();
124+
void correctUserFontIfNeeded();
125+
124126
void notifyAboutCurrentThemeChanged();
127+
125128
void updateCurrentTheme();
126129
void updateThemes();
127130

0 commit comments

Comments
 (0)