mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2026-02-08 00:32:27 +00:00
Change fallback fonts.
This commit is contained in:
@@ -109,6 +109,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
|
||||
engine.rootContext()->setContextProperty("fileIO", &fileIO);
|
||||
engine.rootContext()->setContextProperty("monospaceFontManager", &monospaceFontManager);
|
||||
engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());
|
||||
|
||||
engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "monospacefontmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFont>
|
||||
|
||||
MonospaceFontManager::MonospaceFontManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -23,3 +24,25 @@ QStringList MonospaceFontManager::retrieveMonospaceFonts() {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void MonospaceFontManager::setFontSubstitution(const QString &family, const QString &substitute)
|
||||
{
|
||||
if (family.isEmpty() || substitute.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFont::removeSubstitutions(family);
|
||||
QFont::insertSubstitution(family, substitute);
|
||||
|
||||
qDebug() << "Font substitution set:" << family << "->" << substitute;
|
||||
}
|
||||
|
||||
void MonospaceFontManager::removeFontSubstitution(const QString &family)
|
||||
{
|
||||
if (family.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFont::removeSubstitutions(family);
|
||||
qDebug() << "Font substitution removed for:" << family;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ class MonospaceFontManager : public QObject
|
||||
public:
|
||||
explicit MonospaceFontManager(QObject *parent = nullptr);
|
||||
Q_INVOKABLE QStringList retrieveMonospaceFonts();
|
||||
|
||||
public slots:
|
||||
void setFontSubstitution(const QString &family, const QString &substitute);
|
||||
void removeFontSubstitution(const QString &family);
|
||||
};
|
||||
|
||||
#endif // MONOSPACEFONTMANAGER_H
|
||||
|
||||
@@ -155,6 +155,10 @@ Item{
|
||||
scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling));
|
||||
|
||||
kterminal.lineSpacing = lineSpacing;
|
||||
|
||||
// Set up font fallback based on platform
|
||||
var fallbackFont = appSettings.isMacOS ? "Menlo" : "monospace";
|
||||
monospaceFontManager.setFontSubstitution(fontFamily, fallbackFont);
|
||||
}
|
||||
|
||||
function startSession() {
|
||||
|
||||
Reference in New Issue
Block a user