Font: ensure we never get a 0pt font size during init

This commit is contained in:
Lemmy
2026-01-02 09:55:58 -05:00
parent 2db000c21a
commit 10e1e44e52
5 changed files with 9 additions and 18 deletions
+1 -1
View File
@@ -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
+1 -3
View File
@@ -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
+5 -12
View File
@@ -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"
}
// -------------------------------------------------------
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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