mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Font: ensure we never get a 0pt font size during init
This commit is contained in:
+1
-1
@@ -132,7 +132,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The base/default font size for all text in the bar. 33 is the "default" barHeight
|
// 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 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
|
readonly property color capsuleColor: Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent
|
||||||
|
|||||||
@@ -103,9 +103,7 @@ Rectangle {
|
|||||||
visible: text !== ""
|
visible: text !== ""
|
||||||
text: modelData
|
text: modelData
|
||||||
family: useCustomFont && customFont ? customFont : Settings.data.ui.fontDefault
|
family: useCustomFont && customFont ? customFont : Settings.data.ui.fontDefault
|
||||||
Binding on pointSize {
|
pointSize: Style.barFontSize
|
||||||
value: Style.barFontSize
|
|
||||||
}
|
|
||||||
applyUiScale: false
|
applyUiScale: false
|
||||||
color: usePrimaryColor ? Color.mPrimary : Color.mOnSurface
|
color: usePrimaryColor ? Color.mPrimary : Color.mOnSurface
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|||||||
@@ -893,23 +893,16 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
// Smart formatter for memory values (GB) that prevents elision
|
// Smart formatter for memory values (GB) - max 4 chars
|
||||||
// Tries to keep within 5 chars when possible, rounds if needed
|
// Uses decimal for < 10GB, integer otherwise
|
||||||
function formatMemoryGb(memGb) {
|
function formatMemoryGb(memGb) {
|
||||||
// memGb is already a string from toFixed(1), convert to number
|
|
||||||
const value = parseFloat(memGb);
|
const value = parseFloat(memGb);
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
return "0G";
|
return "0G";
|
||||||
|
|
||||||
// Try with 1 decimal and "G"
|
if (value < 10)
|
||||||
let formatted = value.toFixed(1) + "G";
|
return value.toFixed(1) + "G"; // "0.0G" to "9.9G"
|
||||||
|
return Math.round(value) + "G"; // "10G" to "999G"
|
||||||
// If longer than 5 chars (e.g., "123.4G"), round to integer
|
|
||||||
if (formatted.length > 5) {
|
|
||||||
formatted = Math.round(value) + "G";
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ Text {
|
|||||||
return Icons.get(icon);
|
return Icons.get(icon);
|
||||||
}
|
}
|
||||||
font.family: Icons.fontFamily
|
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
|
color: Color.mOnSurface
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ Text {
|
|||||||
|
|
||||||
font.family: root.family
|
font.family: root.family
|
||||||
font.weight: Style.fontWeightMedium
|
font.weight: Style.fontWeightMedium
|
||||||
font.pointSize: root.pointSize * fontScale
|
font.pointSize: Math.max(1, root.pointSize * fontScale)
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
|||||||
Reference in New Issue
Block a user