mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-11-04 00:52:11 +00:00 
			
		
		
		
	Initial support for system monospace fonts.
This commit is contained in:
		@@ -4,10 +4,12 @@ TARGET = cool-retro-term
 | 
				
			|||||||
DESTDIR = $$OUT_PWD/../
 | 
					DESTDIR = $$OUT_PWD/../
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS += \
 | 
					HEADERS += \
 | 
				
			||||||
    fileio.h
 | 
					    fileio.h \
 | 
				
			||||||
 | 
					    monospacefontmanager.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES = main.cpp \
 | 
					SOURCES = main.cpp \
 | 
				
			||||||
    fileio.cpp
 | 
					    fileio.cpp \
 | 
				
			||||||
 | 
					    monospacefontmanager.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
macx:ICON = icons/crt.icns
 | 
					macx:ICON = icons/crt.icns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,10 @@
 | 
				
			|||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QFontDatabase>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <fileio.h>
 | 
					#include <fileio.h>
 | 
				
			||||||
 | 
					#include <monospacefontmanager.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString getNamedArgument(QStringList args, QString name, QString defaultName)
 | 
					QString getNamedArgument(QStringList args, QString name, QString defaultName)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -42,6 +45,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    QQmlApplicationEngine engine;
 | 
					    QQmlApplicationEngine engine;
 | 
				
			||||||
    FileIO fileIO;
 | 
					    FileIO fileIO;
 | 
				
			||||||
 | 
					    MonospaceFontManager monospaceFontManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(Q_OS_MAC)
 | 
					#if !defined(Q_OS_MAC)
 | 
				
			||||||
    app.setWindowIcon(QIcon::fromTheme("cool-retro-term", QIcon(":../icons/32x32/cool-retro-term.png")));
 | 
					    app.setWindowIcon(QIcon::fromTheme("cool-retro-term", QIcon(":../icons/32x32/cool-retro-term.png")));
 | 
				
			||||||
@@ -83,6 +87,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
 | 
					    engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
 | 
				
			||||||
    engine.rootContext()->setContextProperty("fileIO", &fileIO);
 | 
					    engine.rootContext()->setContextProperty("fileIO", &fileIO);
 | 
				
			||||||
 | 
					    engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());
 | 
					    engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										25
									
								
								app/monospacefontmanager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								app/monospacefontmanager.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					#include "monospacefontmanager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MonospaceFontManager::MonospaceFontManager(QObject *parent) : QObject(parent)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QStringList MonospaceFontManager::retrieveMonospaceFonts() {
 | 
				
			||||||
 | 
					    QStringList result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QFontDatabase fontDatabase;
 | 
				
			||||||
 | 
					    QStringList fontFamilies = fontDatabase.families();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int i = 0; i < fontFamilies.size(); i++) {
 | 
				
			||||||
 | 
					        QString fontFamily = fontFamilies[i];
 | 
				
			||||||
 | 
					        QFont font(fontFamily);
 | 
				
			||||||
 | 
					        if (fontDatabase.isFixedPitch(font.family())) {
 | 
				
			||||||
 | 
					            result.append(fontFamily);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										15
									
								
								app/monospacefontmanager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/monospacefontmanager.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					#ifndef MONOSPACEFONTMANAGER_H
 | 
				
			||||||
 | 
					#define MONOSPACEFONTMANAGER_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QObject>
 | 
				
			||||||
 | 
					#include <QFontDatabase>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MonospaceFontManager : public QObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Q_OBJECT
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit MonospaceFontManager(QObject *parent = nullptr);
 | 
				
			||||||
 | 
					    Q_INVOKABLE QStringList retrieveMonospaceFonts();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // MONOSPACEFONTMANAGER_H
 | 
				
			||||||
@@ -102,7 +102,7 @@ QtObject{
 | 
				
			|||||||
    property var fontNames: ["TERMINUS_SCALED", "COMMODORE_PET", "COMMODORE_PET"]
 | 
					    property var fontNames: ["TERMINUS_SCALED", "COMMODORE_PET", "COMMODORE_PET"]
 | 
				
			||||||
    property var fontlist: fontManager.item.fontlist
 | 
					    property var fontlist: fontManager.item.fontlist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling, real fontWidth)
 | 
					    signal terminalFontChanged(string fontFamily, int pixelSize, int lineSpacing, real screenScaling, real fontWidth)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    signal initializedSettings()
 | 
					    signal initializedSettings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -119,12 +119,15 @@ QtObject{
 | 
				
			|||||||
        onLoaded: handleFontChanged()
 | 
					        onLoaded: handleFontChanged()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    property FontLoader fontLoader: FontLoader { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onFontScalingChanged: handleFontChanged();
 | 
					    onFontScalingChanged: handleFontChanged();
 | 
				
			||||||
    onFontWidthChanged: handleFontChanged();
 | 
					    onFontWidthChanged: handleFontChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function getIndexByName(name) {
 | 
					    function getIndexByName(name) {
 | 
				
			||||||
        for (var i = 0; i < fontlist.count; i++) {
 | 
					        for (var i = 0; i < fontlist.count; i++) {
 | 
				
			||||||
            if (name === fontlist.get(i).name)
 | 
					            var requestedName = fontlist.get(i).name;
 | 
				
			||||||
 | 
					            if (name === requestedName)
 | 
				
			||||||
                return i;
 | 
					                return i;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return 0; // If the font is not available default to 0.
 | 
					        return 0; // If the font is not available default to 0.
 | 
				
			||||||
@@ -154,10 +157,17 @@ QtObject{
 | 
				
			|||||||
        var lineSpacing = fontManager.item.lineSpacing;
 | 
					        var lineSpacing = fontManager.item.lineSpacing;
 | 
				
			||||||
        var screenScaling = fontManager.item.screenScaling;
 | 
					        var screenScaling = fontManager.item.screenScaling;
 | 
				
			||||||
        var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth;
 | 
					        var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth;
 | 
				
			||||||
 | 
					        var fontFamily = fontManager.item.family;
 | 
				
			||||||
 | 
					        var isSystemFont = fontManager.item.isSystemFont;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        lowResolutionFont = fontManager.item.lowResolutionFont;
 | 
					        lowResolutionFont = fontManager.item.lowResolutionFont;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth);
 | 
					        if (!isSystemFont) {
 | 
				
			||||||
 | 
					            fontLoader.source = fontSource;
 | 
				
			||||||
 | 
					            fontFamily = fontLoader.name;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        terminalFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // FRAMES /////////////////////////////////////////////////////////////////
 | 
					    // FRAMES /////////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -496,7 +506,7 @@ QtObject{
 | 
				
			|||||||
    Component.onDestruction: {
 | 
					    Component.onDestruction: {
 | 
				
			||||||
        storeSettings();
 | 
					        storeSettings();
 | 
				
			||||||
        storeCustomProfiles();
 | 
					        storeCustomProfiles();
 | 
				
			||||||
        //storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!!
 | 
					//        storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!!
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // VARS ///////////////////////////////////////////////////////////////////
 | 
					    // VARS ///////////////////////////////////////////////////////////////////
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,10 @@ QtObject{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
 | 
					    property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    property string family: fontlist.get(selectedFontIndex).family
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    property bool isSystemFont: fontlist.get(selectedFontIndex).isSystemFont
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // There are two kind of fonts: low resolution and high resolution.
 | 
					    // There are two kind of fonts: low resolution and high resolution.
 | 
				
			||||||
    // Low resolution font sets the lowResolutionFont property to true.
 | 
					    // Low resolution font sets the lowResolutionFont property to true.
 | 
				
			||||||
    // They are rendered at a fixed pixel size and the texture is upscaled
 | 
					    // They are rendered at a fixed pixel size and the texture is upscaled
 | 
				
			||||||
@@ -49,7 +53,7 @@ QtObject{
 | 
				
			|||||||
    // size of the screen, and the scaling directly controls their pixels size.
 | 
					    // size of the screen, and the scaling directly controls their pixels size.
 | 
				
			||||||
    // Those are slower to render but are not pixelated.
 | 
					    // Those are slower to render but are not pixelated.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property ListModel fontlist: ListModel{
 | 
					    property ListModel fontlist: ListModel {
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "TERMINUS_SCALED"
 | 
					            name: "TERMINUS_SCALED"
 | 
				
			||||||
            text: "Terminus (Modern)"
 | 
					            text: "Terminus (Modern)"
 | 
				
			||||||
@@ -59,6 +63,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.0
 | 
					            baseScaling: 3.0
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "PRO_FONT_SCALED"
 | 
					            name: "PRO_FONT_SCALED"
 | 
				
			||||||
@@ -69,6 +75,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.0
 | 
					            baseScaling: 3.0
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "EXCELSIOR_SCALED"
 | 
					            name: "EXCELSIOR_SCALED"
 | 
				
			||||||
@@ -79,6 +87,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 2.4
 | 
					            baseScaling: 2.4
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "COMMODORE_PET_SCALED"
 | 
					            name: "COMMODORE_PET_SCALED"
 | 
				
			||||||
@@ -89,6 +99,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.5
 | 
					            baseScaling: 3.5
 | 
				
			||||||
            fontWidth: 0.7
 | 
					            fontWidth: 0.7
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "PROGGY_TINY_SCALED"
 | 
					            name: "PROGGY_TINY_SCALED"
 | 
				
			||||||
@@ -99,6 +111,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.0
 | 
					            baseScaling: 3.0
 | 
				
			||||||
            fontWidth: 0.9
 | 
					            fontWidth: 0.9
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "APPLE_II_SCALED"
 | 
					            name: "APPLE_II_SCALED"
 | 
				
			||||||
@@ -109,6 +123,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.5
 | 
					            baseScaling: 3.5
 | 
				
			||||||
            fontWidth: 0.8
 | 
					            fontWidth: 0.8
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "ATARI_400_SCALED"
 | 
					            name: "ATARI_400_SCALED"
 | 
				
			||||||
@@ -119,6 +135,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.5
 | 
					            baseScaling: 3.5
 | 
				
			||||||
            fontWidth: 0.7
 | 
					            fontWidth: 0.7
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "COMMODORE_64_SCALED"
 | 
					            name: "COMMODORE_64_SCALED"
 | 
				
			||||||
@@ -129,6 +147,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 3.5
 | 
					            baseScaling: 3.5
 | 
				
			||||||
            fontWidth: 0.7
 | 
					            fontWidth: 0.7
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "ATARI_ST_SCALED"
 | 
					            name: "ATARI_ST_SCALED"
 | 
				
			||||||
@@ -139,6 +159,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 2.0
 | 
					            baseScaling: 2.0
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "IBM_DOS"
 | 
					            name: "IBM_DOS"
 | 
				
			||||||
@@ -149,6 +171,8 @@ QtObject{
 | 
				
			|||||||
            baseScaling: 2.0
 | 
					            baseScaling: 2.0
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "HERMIT"
 | 
					            name: "HERMIT"
 | 
				
			||||||
@@ -158,6 +182,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 28
 | 
					            pixelSize: 28
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "TERMINUS"
 | 
					            name: "TERMINUS"
 | 
				
			||||||
@@ -167,6 +193,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 35
 | 
					            pixelSize: 35
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "PRO_FONT"
 | 
					            name: "PRO_FONT"
 | 
				
			||||||
@@ -176,6 +204,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 35
 | 
					            pixelSize: 35
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "MONACO"
 | 
					            name: "MONACO"
 | 
				
			||||||
@@ -185,6 +215,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 30
 | 
					            pixelSize: 30
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "INCONSOLATA"
 | 
					            name: "INCONSOLATA"
 | 
				
			||||||
@@ -194,6 +226,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 35
 | 
					            pixelSize: 35
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "IBM_3278"
 | 
					            name: "IBM_3278"
 | 
				
			||||||
@@ -203,6 +237,8 @@ QtObject{
 | 
				
			|||||||
            pixelSize: 32
 | 
					            pixelSize: 32
 | 
				
			||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            lowResolutionFont: false
 | 
					            lowResolutionFont: false
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ListElement{
 | 
					        ListElement{
 | 
				
			||||||
            name: "Knight_TV"
 | 
					            name: "Knight_TV"
 | 
				
			||||||
@@ -213,6 +249,33 @@ QtObject{
 | 
				
			|||||||
            fontWidth: 1.0
 | 
					            fontWidth: 1.0
 | 
				
			||||||
            baseScaling: 3.0
 | 
					            baseScaling: 3.0
 | 
				
			||||||
            lowResolutionFont: true
 | 
					            lowResolutionFont: true
 | 
				
			||||||
 | 
					            isSystemFont: false
 | 
				
			||||||
 | 
					            family: ""
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Component.onCompleted: addSystemFonts()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function addSystemFonts() {
 | 
				
			||||||
 | 
					        var families = monospaceSystemFonts;
 | 
				
			||||||
 | 
					        for (var i = 0; i < families.length; i++) {
 | 
				
			||||||
 | 
					            console.log("Adding system font: ", families[i])
 | 
				
			||||||
 | 
					            fontlist.append(convertToListElement(families[i]))
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function convertToListElement(family) {
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            name: "System: " + family,
 | 
				
			||||||
 | 
					            text: qsTr("System: ") + family,
 | 
				
			||||||
 | 
					            source: "",
 | 
				
			||||||
 | 
					            lineSpacing: 0.1,
 | 
				
			||||||
 | 
					            pixelSize: 30,
 | 
				
			||||||
 | 
					            fontWidth: 1.0,
 | 
				
			||||||
 | 
					            baseScaling: 1.0,
 | 
				
			||||||
 | 
					            lowResolutionFont: false,
 | 
				
			||||||
 | 
					            isSystemFont: true,
 | 
				
			||||||
 | 
					            family: family
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -114,14 +114,10 @@ Item{
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        FontLoader{ id: fontLoader }
 | 
					        function handleFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth){
 | 
					 | 
				
			||||||
            fontLoader.source = fontSource;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            kterminal.antialiasText = !appSettings.lowResolutionFont;
 | 
					            kterminal.antialiasText = !appSettings.lowResolutionFont;
 | 
				
			||||||
            font.pixelSize = pixelSize;
 | 
					            font.pixelSize = pixelSize;
 | 
				
			||||||
            font.family = fontLoader.name;
 | 
					            font.family = fontFamily;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            terminalContainer.fontWidth = fontWidth;
 | 
					            terminalContainer.fontWidth = fontWidth;
 | 
				
			||||||
            terminalContainer.screenScaling = screenScaling;
 | 
					            terminalContainer.screenScaling = screenScaling;
 | 
				
			||||||
@@ -129,6 +125,7 @@ Item{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            kterminal.lineSpacing = lineSpacing;
 | 
					            kterminal.lineSpacing = lineSpacing;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function startSession() {
 | 
					        function startSession() {
 | 
				
			||||||
            appSettings.initializedSettings.disconnect(startSession);
 | 
					            appSettings.initializedSettings.disconnect(startSession);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -152,7 +149,7 @@ Item{
 | 
				
			|||||||
            forceActiveFocus();
 | 
					            forceActiveFocus();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Component.onCompleted: {
 | 
					        Component.onCompleted: {
 | 
				
			||||||
            appSettings.terminalFontChanged.connect(handleFontChange);
 | 
					            appSettings.terminalFontChanged.connect(handleFontChanged);
 | 
				
			||||||
            appSettings.initializedSettings.connect(startSession);
 | 
					            appSettings.initializedSettings.connect(startSession);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user