Repository navigation
Fix fallback to wrong icon font - #1018
Conversation
d3739cf to
29d7311
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the app’s icon-font loading so Font Awesome/RemixIcon glyph rendering no longer falls back to an unintended system font, by ensuring the correct embedded fonts are loaded and selected at runtime.
Changes:
- Switch the bundled Font Awesome asset from v6 to v7 in the Qt resource file.
- Move application font loading/selection logic into
fonticon.cppand select the loaded family name rather than hard-coding it. - Remove eager font registration from
Platform::setApplication().
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/resources/fonticon.cpp | Adds runtime loading of embedded icon fonts and uses the loaded font family names for rendering. |
| src/resources/client.qrc | Updates the embedded Font Awesome resource from v6 to v7. |
| src/libsync/platform.cpp | Removes eager font registration during application setup. |
Suppressed comments (1)
src/resources/fonticon.cpp:43
QFontDatabase::applicationFontFamilies(id).last()is undefined/asserts when the list is empty (possible if the font loads but reports no families). This can crash in debug builds.
qCDebug(lcFontIcon) << "Loaded font: remixicon.ttf" << QFontDatabase::applicationFontFamilies(id);
// the list might contain multiple entries, so we take the last one, which is the most exact match
return QFontDatabase::applicationFontFamilies(id).last();
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #include <QFontDatabase> | ||
| #include <QIconEngine> |
| static QString fontAwesomeFamily = [] { | ||
| if (int id = QFontDatabase::addApplicationFont(QStringLiteral(":/client/font-awesome/Font Awesome 7 Free-Solid-900.otf")); id == -1) { | ||
| qCWarning(lcFontIcon) << "Failed to load font: Font Awesome 7 Free-Solid-900.otf"; | ||
| } else { | ||
| qCDebug(lcFontIcon) << "Loaded font: Font Awesome 7 Free-Solid-900.otf" << QFontDatabase::applicationFontFamilies(id); | ||
| // the list might contain multiple entries, so we take the last one, which is the most exact match | ||
| return QFontDatabase::applicationFontFamilies(id).last(); | ||
| } | ||
| return QString{}; | ||
| }(); |
There was a problem hiding this comment.
A crash would even be good (and discovered fast in testing) since we load from our resource. So i think this comment can be ignored? @TheOneRing
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/resources/fonticon.cpp:11
QFileInfoandQ_LOGGING_CATEGORY/qC*macros are used in this file, but the corresponding headers aren’t included. Depending on transitive includes, this can fail to compile or break when includes change.
#include <QFontDatabase>
#include <QIconEngine>
#include <QPainter>
#include <QPixmapCache>
src/resources/fonticon.cpp:35
QFontDatabase::applicationFontFamilies(id)is called twice; store it once to avoid duplicate work and to keep the debug output/return value consistent.
qCDebug(lcFontIcon) << u"Loaded font:" << info.fileName() << QFontDatabase::applicationFontFamilies(id);
// the list might contain multiple entries, so we take the last one, which is the most exact match
return QFontDatabase::applicationFontFamilies(id).last();
}
Use the most exact font name as possible to prevent fallback to wrong fonts
Apparently, a slightly misconfigured font config can cause a fallback to a random system font if we request
"Font Awesome 6 Free" instead of "Font Awesome 6 Free Solid"