Initial support for system monospace fonts.
This commit is contained in:
@@ -102,7 +102,7 @@ QtObject{
|
||||
property var fontNames: ["TERMINUS_SCALED", "COMMODORE_PET", "COMMODORE_PET"]
|
||||
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()
|
||||
|
||||
@@ -119,12 +119,15 @@ QtObject{
|
||||
onLoaded: handleFontChanged()
|
||||
}
|
||||
|
||||
property FontLoader fontLoader: FontLoader { }
|
||||
|
||||
onFontScalingChanged: handleFontChanged();
|
||||
onFontWidthChanged: handleFontChanged();
|
||||
|
||||
function getIndexByName(name) {
|
||||
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 0; // If the font is not available default to 0.
|
||||
@@ -154,10 +157,17 @@ QtObject{
|
||||
var lineSpacing = fontManager.item.lineSpacing;
|
||||
var screenScaling = fontManager.item.screenScaling;
|
||||
var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth;
|
||||
var fontFamily = fontManager.item.family;
|
||||
var isSystemFont = fontManager.item.isSystemFont;
|
||||
|
||||
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 /////////////////////////////////////////////////////////////////
|
||||
@@ -496,7 +506,7 @@ QtObject{
|
||||
Component.onDestruction: {
|
||||
storeSettings();
|
||||
storeCustomProfiles();
|
||||
//storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!!
|
||||
// storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!!
|
||||
}
|
||||
|
||||
// VARS ///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -41,6 +41,10 @@ QtObject{
|
||||
|
||||
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.
|
||||
// Low resolution font sets the lowResolutionFont property to true.
|
||||
// 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.
|
||||
// Those are slower to render but are not pixelated.
|
||||
|
||||
property ListModel fontlist: ListModel{
|
||||
property ListModel fontlist: ListModel {
|
||||
ListElement{
|
||||
name: "TERMINUS_SCALED"
|
||||
text: "Terminus (Modern)"
|
||||
@@ -59,6 +63,8 @@ QtObject{
|
||||
baseScaling: 3.0
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "PRO_FONT_SCALED"
|
||||
@@ -69,6 +75,8 @@ QtObject{
|
||||
baseScaling: 3.0
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "EXCELSIOR_SCALED"
|
||||
@@ -79,6 +87,8 @@ QtObject{
|
||||
baseScaling: 2.4
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "COMMODORE_PET_SCALED"
|
||||
@@ -89,6 +99,8 @@ QtObject{
|
||||
baseScaling: 3.5
|
||||
fontWidth: 0.7
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "PROGGY_TINY_SCALED"
|
||||
@@ -99,6 +111,8 @@ QtObject{
|
||||
baseScaling: 3.0
|
||||
fontWidth: 0.9
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "APPLE_II_SCALED"
|
||||
@@ -109,6 +123,8 @@ QtObject{
|
||||
baseScaling: 3.5
|
||||
fontWidth: 0.8
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "ATARI_400_SCALED"
|
||||
@@ -119,6 +135,8 @@ QtObject{
|
||||
baseScaling: 3.5
|
||||
fontWidth: 0.7
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "COMMODORE_64_SCALED"
|
||||
@@ -129,6 +147,8 @@ QtObject{
|
||||
baseScaling: 3.5
|
||||
fontWidth: 0.7
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "ATARI_ST_SCALED"
|
||||
@@ -139,6 +159,8 @@ QtObject{
|
||||
baseScaling: 2.0
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "IBM_DOS"
|
||||
@@ -149,6 +171,8 @@ QtObject{
|
||||
baseScaling: 2.0
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: true
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "HERMIT"
|
||||
@@ -158,6 +182,8 @@ QtObject{
|
||||
pixelSize: 28
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "TERMINUS"
|
||||
@@ -167,6 +193,8 @@ QtObject{
|
||||
pixelSize: 35
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "PRO_FONT"
|
||||
@@ -176,6 +204,8 @@ QtObject{
|
||||
pixelSize: 35
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "MONACO"
|
||||
@@ -185,6 +215,8 @@ QtObject{
|
||||
pixelSize: 30
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "INCONSOLATA"
|
||||
@@ -194,6 +226,8 @@ QtObject{
|
||||
pixelSize: 35
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "IBM_3278"
|
||||
@@ -203,6 +237,8 @@ QtObject{
|
||||
pixelSize: 32
|
||||
fontWidth: 1.0
|
||||
lowResolutionFont: false
|
||||
isSystemFont: false
|
||||
family: ""
|
||||
}
|
||||
ListElement{
|
||||
name: "Knight_TV"
|
||||
@@ -213,6 +249,33 @@ QtObject{
|
||||
fontWidth: 1.0
|
||||
baseScaling: 3.0
|
||||
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 handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth){
|
||||
fontLoader.source = fontSource;
|
||||
|
||||
function handleFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth) {
|
||||
kterminal.antialiasText = !appSettings.lowResolutionFont;
|
||||
font.pixelSize = pixelSize;
|
||||
font.family = fontLoader.name;
|
||||
font.family = fontFamily;
|
||||
|
||||
terminalContainer.fontWidth = fontWidth;
|
||||
terminalContainer.screenScaling = screenScaling;
|
||||
@@ -129,6 +125,7 @@ Item{
|
||||
|
||||
kterminal.lineSpacing = lineSpacing;
|
||||
}
|
||||
|
||||
function startSession() {
|
||||
appSettings.initializedSettings.disconnect(startSession);
|
||||
|
||||
@@ -152,7 +149,7 @@ Item{
|
||||
forceActiveFocus();
|
||||
}
|
||||
Component.onCompleted: {
|
||||
appSettings.terminalFontChanged.connect(handleFontChange);
|
||||
appSettings.terminalFontChanged.connect(handleFontChanged);
|
||||
appSettings.initializedSettings.connect(startSession);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user