diff options
| author | Doris Verria <doris.verria@qt.io> | 2026-09-17 23:11:24 +0200 |
|---|---|---|
| committer | Doris Verria <doris.verria@qt.io> | 2026-09-29 09:22:38 +0000 |
| commit | f6940d5102253ea992bdb457843e08dbe3f947dd (patch) | |
| tree | b636e64c7175bf8b52984d29a560b3c73aee2fa4 | |
| parent | 40ad27761b4618cb9e9a70f8675f3392e94372c0 (diff) | |
QQStyleKitTheme: Keep the font resolve mask when merging font scopes
QFont::resolve() returns only the left-hand operand's resolve mask,
unlike QPalette::resolve() which ORs both, so each step of the fallback
chain in updateThemeFonts() collapsed the accumulated mask down to the
nearest layer's. Setting fonts.system.bold in a theme therefore produced
a font still holding the style's family and pointSize as values, but
with a mask claiming only Weight. To fix, set the resolve mask to the
union explicitly.
Pick-to: 6.12
Change-Id: Ib802a8ce3d8a5760bc9639631080a25d5e2658df
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| -rw-r--r-- | src/labs/stylekit/qqstylekittheme.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/labs/stylekit/qqstylekittheme.cpp b/src/labs/stylekit/qqstylekittheme.cpp index a0dfdb7d4f..6edb8de25c 100644 --- a/src/labs/stylekit/qqstylekittheme.cpp +++ b/src/labs/stylekit/qqstylekittheme.cpp @@ -197,6 +197,15 @@ void QQStyleKitTheme::updateThemeFonts() for (auto *fb = fonts; fb; fb = fb->fallbackFont()) fbChain.append(fb); + // QFont::resolve() keeps only the left-hand operand's resolve mask. + // Restore the mask explicitly, or every attribute contributed by an + // earlier layer of the chain is dropped again by font resolution. + auto merge = [](const QFont &a, const QFont &b) { + QFont merged = a.resolve(b); + merged.setResolveMask(b.resolveMask() | a.resolveMask()); + return merged; + }; + auto resolveFromFontChain = [&](QQuickTheme::Scope scope) -> QFont { QFont result; @@ -206,10 +215,10 @@ void QQStyleKitTheme::updateThemeFonts() const QQStyleKitFont *fb = fbChain[i]; // Apply system font first as a base, and override with scope-specific font if (scope != QQuickTheme::System && fb->isSet(QQuickTheme::System)) { - result = fb->fontForScope(QQuickTheme::System).resolve(result); + result = merge(fb->fontForScope(QQuickTheme::System), result); } if (fb->isSet(scope)) { - result = fb->fontForScope(scope).resolve(result); + result = merge(fb->fontForScope(scope), result); } } |
