Skip to content

Fix fallback to wrong icon font - #1018

Merged
TheOneRing merged 1 commit into
mainfrom
work/font
Aug 11, 2026
Merged

TheOneRing merged 1 commit into
mainfrom
work/font

Conversation

@TheOneRing

@TheOneRing TheOneRing commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

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"

@TheOneRing TheOneRing linked an issue Aug 6, 2026 that may be closed by this pull request
@TheOneRing
TheOneRing force-pushed the work/font branch 5 times, most recently from d3739cf to 29d7311 Compare August 10, 2026 13:53
@TheOneRing TheOneRing changed the title Log if icon fon't was not found Fix fallback to wrong icon font Aug 10, 2026
@TheOneRing
TheOneRing requested review from guruz and a lite review from Copilot August 10, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cpp and 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.

Comment on lines +8 to 9
#include <QFontDatabase>
#include <QIconEngine>
Comment thread src/resources/fonticon.cpp Outdated
Comment on lines +21 to +30
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{};
}();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • QFileInfo and Q_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();
    }

Comment thread src/resources/fonticon.cpp Resolved
Use the most exact font name as possible to prevent fallback to wrong fonts
@TheOneRing
TheOneRing merged commit f99eaa8 into main Aug 11, 2026
13 checks passed
@TheOneRing
TheOneRing deleted the work/font branch August 11, 2026 10:19
@openclouders openclouders mentioned this pull request Aug 11, 2026
1 task
@saw-jan saw-jan mentioned this pull request Sep 2, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fontconfig problems on Linux

3 participants