https://bugs.kde.org/show_bug.cgi?id=523028

            Bug ID: 523028
           Summary: Make runtime Noto Sans / Hack font defaults
                    configurable at CMake time and degrade gracefully when
                    absent
    Classification: Plasma
           Product: plasma-integration
      Version First master
       Reported In:
          Platform: unspecified
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

KDEPlasmaPlatformTheme6.so (built from plasma-integration) hardcodes "Noto
Sans" as
the default UI font for six font slots and "Hack" for the monospace slot in
qt6/src/platformtheme/kfontsettingsdata.cpp:41-50. This makes every downstream
distro implicitly depend on Noto Sans -- distros that standardize on a
different
sans (Cantarell, Inter, IBM Plex) cannot override the platform theme's default
without patching source. The kconf_update migration script (fonts_global.pl)
further rewrites user configs to "Noto Sans" on upgrade, making the
brand-default
invasive even when Noto isn't installed.

The CMake side already half-supports this: CMakeLists.txt exposes
find_package(FontNotoSans) with a
-DCMAKE_DISABLE_FIND_PACKAGE_FontNotoSans=true
escape hatch, but it only suppresses a build-time warning; the literal in
kfontsettingsdata.cpp is unchanged. The hook is there, the matching source-side
change isn't.

Prior community discussion on the resulting hard dep: Gentoo bug 922794 (open),
Arch BBS 294551, Debian/Ubuntu ship it as soft Recommends: instead of hard
Depends: -- proving the plugin works without Noto.

PROPOSED FIX (hybrid, two small additive changes)

(a) Expose defaults as CMake cache variables, with current values as defaults
so
    an unset build is byte-equivalent:

    set(PLASMA_INTEGRATION_DEFAULT_SANS_FONT "Noto Sans"
        CACHE STRING "Default sans-serif font family used by the platform theme
        when the user has not set one in kdeglobals.")
    set(PLASMA_INTEGRATION_DEFAULT_MONO_FONT "Hack"
        CACHE STRING "Default monospace font family used by the platform theme
        when the user has not set one in kdeglobals.")
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kfontdefaults.h.in
                   ${CMAKE_CURRENT_BINARY_DIR}/generated/kfontdefaults.h @ONLY)

(b) Add a runtime fallback in KFontSettingsData::font() so a missing compiled
    default gracefully resolves via fontconfig's sans-serif/monospace alias
    instead of producing a QFont whose family silently fails every paint:

    if (!QFontDatabase::families().contains(compiledFamily))
        cachedFont = new QFont();  // empty family -> fontconfig sans-serif /
mono

BACKWARD COMPATIBILITY

- Unset build produces an identical binary (defaults match current literals).
- find_package(FontNotoSans) is preserved so distros that want the runtime hint
  still see it.
- kconf_update migration scripts are untouched in this change (a sensible
  follow-up, but a separate concern).

TEST PLAN

1. Default build: strings build/.../KDEPlasmaPlatformTheme6.so | grep 'Noto
Sans'
   returns identical output to current master.
2. Override build: cmake -B build -S .
-DPLASMA_INTEGRATION_DEFAULT_SANS_FONT=Cantarell
   -- generated header contains "Cantarell" and the binary's string table
reflects it.
3. Runtime fallback: with the compiled default uninstalled, launch a Qt app
under
   the platform theme and verify qDebug() << QApplication::font().family()
returns
   the fontconfig alias, not the missing family.

RELATED

- VDG rationale for the original Noto Sans switch: commit 4d274c9 (2015).
  The argument holds; the implementation shouldn't be welded to one font brand.
- Hack switch: commit 0ad3465 (2016).
- Patch (3 files, ~40 net lines) ready to attach as a merge request on
  invent.kde.org/plasma/plasma-integration once bug number is assigned.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to