From 10e1e44e52fd6c2f2d415d447a2642f5ef10b1de Mon Sep 17 00:00:00 2001 From: Lemmy Date: Fri, 2 Jan 2026 09:55:58 -0500 Subject: [PATCH] Font: ensure we never get a 0pt font size during init --- Commons/Style.qml | 2 +- Modules/Bar/Widgets/Clock.qml | 4 +--- Services/System/SystemStatService.qml | 17 +++++------------ Widgets/NIcon.qml | 2 +- Widgets/NText.qml | 2 +- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Commons/Style.qml b/Commons/Style.qml index e8f24bd38..91f1eee79 100644 --- a/Commons/Style.qml +++ b/Commons/Style.qml @@ -132,7 +132,7 @@ Singleton { } // The base/default font size for all text in the bar. 33 is the "default" barHeight - readonly property real _barBaseFontSize: (Style.barHeight / 33) * Style.fontSizeS + readonly property real _barBaseFontSize: Math.max(1, (Style.barHeight / 33) * Style.fontSizeS) readonly property real barFontSize: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? _barBaseFontSize * 0.9 : _barBaseFontSize readonly property color capsuleColor: Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent diff --git a/Modules/Bar/Widgets/Clock.qml b/Modules/Bar/Widgets/Clock.qml index 544656a6d..523e24c29 100644 --- a/Modules/Bar/Widgets/Clock.qml +++ b/Modules/Bar/Widgets/Clock.qml @@ -103,9 +103,7 @@ Rectangle { visible: text !== "" text: modelData family: useCustomFont && customFont ? customFont : Settings.data.ui.fontDefault - Binding on pointSize { - value: Style.barFontSize - } + pointSize: Style.barFontSize applyUiScale: false color: usePrimaryColor ? Color.mPrimary : Color.mOnSurface wrapMode: Text.WordWrap diff --git a/Services/System/SystemStatService.qml b/Services/System/SystemStatService.qml index 0ede9c116..381db508e 100644 --- a/Services/System/SystemStatService.qml +++ b/Services/System/SystemStatService.qml @@ -893,23 +893,16 @@ Singleton { } // ------------------------------------------------------- - // Smart formatter for memory values (GB) that prevents elision - // Tries to keep within 5 chars when possible, rounds if needed + // Smart formatter for memory values (GB) - max 4 chars + // Uses decimal for < 10GB, integer otherwise function formatMemoryGb(memGb) { - // memGb is already a string from toFixed(1), convert to number const value = parseFloat(memGb); if (isNaN(value)) return "0G"; - // Try with 1 decimal and "G" - let formatted = value.toFixed(1) + "G"; - - // If longer than 5 chars (e.g., "123.4G"), round to integer - if (formatted.length > 5) { - formatted = Math.round(value) + "G"; - } - - return formatted; + if (value < 10) + return value.toFixed(1) + "G"; // "0.0G" to "9.9G" + return Math.round(value) + "G"; // "10G" to "999G" } // ------------------------------------------------------- diff --git a/Widgets/NIcon.qml b/Widgets/NIcon.qml index eeabc712b..834702ac3 100644 --- a/Widgets/NIcon.qml +++ b/Widgets/NIcon.qml @@ -23,7 +23,7 @@ Text { return Icons.get(icon); } font.family: Icons.fontFamily - font.pointSize: applyUiScale ? root.pointSize * Style.uiScaleRatio : root.pointSize + font.pointSize: Math.max(1, applyUiScale ? root.pointSize * Style.uiScaleRatio : root.pointSize) color: Color.mOnSurface verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter diff --git a/Widgets/NText.qml b/Widgets/NText.qml index 72f2b816a..41996be07 100644 --- a/Widgets/NText.qml +++ b/Widgets/NText.qml @@ -20,7 +20,7 @@ Text { font.family: root.family font.weight: Style.fontWeightMedium - font.pointSize: root.pointSize * fontScale + font.pointSize: Math.max(1, root.pointSize * fontScale) color: Color.mOnSurface elide: Text.ElideRight wrapMode: Text.NoWrap