Replace hardcoded font with check for default fonts, fall back to
inter/roboto Settings: use font detection function GeneralTab: let user know that it uses default fonts and falls back to inter/roboto FontService: add proper checks for default fonts (sans & mono)
This commit is contained in:
parent
62b12d5436
commit
be4a69f6e0
3 changed files with 126 additions and 3 deletions
|
|
@ -203,6 +203,17 @@ Singleton {
|
||||||
BluetoothService.init()
|
BluetoothService.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------
|
||||||
|
// Update font defaults when system fonts are detected
|
||||||
|
function updateFontDefaults() {
|
||||||
|
if (FontService.systemFontsDetected) {
|
||||||
|
Logger.log("Settings", "Updating font defaults with detected system fonts")
|
||||||
|
adapter.ui.fontDefault = FontService.getSystemSansFont()
|
||||||
|
adapter.ui.fontFixed = FontService.getSystemMonospaceFont()
|
||||||
|
adapter.ui.fontBillboard = FontService.getSystemDisplayFont()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
// Ensure directories exist before FileView tries to read files
|
// Ensure directories exist before FileView tries to read files
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
@ -213,6 +224,9 @@ Singleton {
|
||||||
|
|
||||||
// Mark directories as created and trigger file loading
|
// Mark directories as created and trigger file loading
|
||||||
directoriesCreated = true
|
directoriesCreated = true
|
||||||
|
|
||||||
|
// Connect to font service signal to update defaults when system fonts are detected
|
||||||
|
FontService.systemFontsDetected.connect(updateFontDefaults)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't write settings to disk immediately
|
// Don't write settings to disk immediately
|
||||||
|
|
@ -415,9 +429,9 @@ Singleton {
|
||||||
|
|
||||||
// ui
|
// ui
|
||||||
property JsonObject ui: JsonObject {
|
property JsonObject ui: JsonObject {
|
||||||
property string fontDefault: "Roboto"
|
property string fontDefault: FontService.getSystemSansFont()
|
||||||
property string fontFixed: "DejaVu Sans Mono"
|
property string fontFixed: FontService.getSystemMonospaceFont()
|
||||||
property string fontBillboard: "Inter"
|
property string fontBillboard: FontService.getSystemDisplayFont()
|
||||||
property list<var> monitorsScaling: []
|
property list<var> monitorsScaling: []
|
||||||
property bool idleInhibitorEnabled: false
|
property bool idleInhibitorEnabled: false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,15 @@ ColumnLayout {
|
||||||
Layout.bottomMargin: Style.marginS * scaling
|
Layout.bottomMargin: Style.marginS * scaling
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NText {
|
||||||
|
text: "Fonts are automatically detected from your system. Inter/Roboto are used as fallbacks when system fonts cannot be detected."
|
||||||
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
|
color: Color.mOnSurfaceVariant
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: Style.marginM * scaling
|
||||||
|
}
|
||||||
|
|
||||||
// Font configuration section
|
// Font configuration section
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: Style.marginL * scaling
|
spacing: Style.marginL * scaling
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ pragma Singleton
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
|
|
@ -13,12 +14,29 @@ Singleton {
|
||||||
property ListModel displayFonts: ListModel {}
|
property ListModel displayFonts: ListModel {}
|
||||||
property bool fontsLoaded: false
|
property bool fontsLoaded: false
|
||||||
|
|
||||||
|
// System font detection
|
||||||
|
property string systemSansFont: ""
|
||||||
|
property string systemMonospaceFont: ""
|
||||||
|
property string systemDisplayFont: ""
|
||||||
|
property bool systemFontsDetected: false
|
||||||
|
|
||||||
|
// Signal emitted when system font detection is complete
|
||||||
|
signal systemFontsDetected
|
||||||
|
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
function init() {
|
function init() {
|
||||||
Logger.log("Font", "Service started")
|
Logger.log("Font", "Service started")
|
||||||
|
detectSystemFonts()
|
||||||
loadSystemFonts()
|
loadSystemFonts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function detectSystemFonts() {
|
||||||
|
Logger.log("Font", "Detecting system fonts...")
|
||||||
|
|
||||||
|
// Start detecting sans-serif font
|
||||||
|
sansFontProcess.running = true
|
||||||
|
}
|
||||||
|
|
||||||
function loadSystemFonts() {
|
function loadSystemFonts() {
|
||||||
Logger.log("Font", "Loading system fonts...")
|
Logger.log("Font", "Loading system fonts...")
|
||||||
|
|
||||||
|
|
@ -158,4 +176,86 @@ Singleton {
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get system font with fallback
|
||||||
|
function getSystemSansFont() {
|
||||||
|
if (systemSansFont && systemSansFont !== "") {
|
||||||
|
return systemSansFont
|
||||||
|
}
|
||||||
|
return "Roboto" // Fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSystemMonospaceFont() {
|
||||||
|
if (systemMonospaceFont && systemMonospaceFont !== "") {
|
||||||
|
return systemMonospaceFont
|
||||||
|
}
|
||||||
|
return "DejaVu Sans Mono" // Fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSystemDisplayFont() {
|
||||||
|
if (systemDisplayFont && systemDisplayFont !== "") {
|
||||||
|
return systemDisplayFont
|
||||||
|
}
|
||||||
|
return "Inter" // Fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process for detecting sans fonts
|
||||||
|
Process {
|
||||||
|
id: sansFontProcess
|
||||||
|
command: ["fc-match", "-f", "%{family[0]}\n", "sans"]
|
||||||
|
onExited: function (exitCode) {
|
||||||
|
if (exitCode === 0) {
|
||||||
|
var fontName = stdout.text.trim()
|
||||||
|
if (fontName !== "") {
|
||||||
|
systemSansFont = fontName
|
||||||
|
Logger.log("Font", "Detected system sans font:", systemSansFont)
|
||||||
|
} else {
|
||||||
|
Logger.warn("Font", "Empty result for system sans font, will use fallback")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.warn("Font", "Failed to detect system sans font, will use fallback")
|
||||||
|
}
|
||||||
|
// Start detecting monospace font
|
||||||
|
monoFontProcess.running = true
|
||||||
|
}
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
stderr: StdioCollector {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process for detecting mono fonts
|
||||||
|
Process {
|
||||||
|
id: monoFontProcess
|
||||||
|
command: ["fc-match", "-f", "%{family[0]}\n", "monospace"]
|
||||||
|
onExited: function (exitCode) {
|
||||||
|
if (exitCode === 0) {
|
||||||
|
var fontName = stdout.text.trim()
|
||||||
|
if (fontName !== "") {
|
||||||
|
systemMonospaceFont = fontName
|
||||||
|
Logger.log("Font", "Detected system monospace font:", systemMonospaceFont)
|
||||||
|
} else {
|
||||||
|
Logger.warn("Font", "Empty result for system monospace font, will use fallback")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.warn("Font", "Failed to detect system monospace font, will use fallback")
|
||||||
|
}
|
||||||
|
// for now we'll use the same font for display as sans
|
||||||
|
systemDisplayFont = systemSansFont
|
||||||
|
|
||||||
|
// Log the final font choices after all detection is complete
|
||||||
|
Logger.log("Font", "=== FONT DETECTION RESULTS ===")
|
||||||
|
Logger.log("Font", "System Sans Font:", systemSansFont || "NOT DETECTED")
|
||||||
|
Logger.log("Font", "System Monospace Font:", systemMonospaceFont || "NOT DETECTED")
|
||||||
|
Logger.log("Font", "System Display Font:", systemDisplayFont || "NOT DETECTED")
|
||||||
|
Logger.log("Font", "=== FINAL FONT DEFAULTS ===")
|
||||||
|
Logger.log("Font", "Default Font (getSystemSansFont):", getSystemSansFont())
|
||||||
|
Logger.log("Font", "Fixed Font (getSystemMonospaceFont):", getSystemMonospaceFont())
|
||||||
|
Logger.log("Font", "Billboard Font (getSystemDisplayFont):", getSystemDisplayFont())
|
||||||
|
|
||||||
|
// Mark detection as complete and emit signal
|
||||||
|
systemFontsDetected = true
|
||||||
|
systemFontsDetected()
|
||||||
|
}
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
stderr: StdioCollector {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue