Fix: using font names instaed of indexes in settings.

This commit is contained in:
Filippo Scognamiglio 2014-12-16 01:22:46 +01:00
parent fa59bb06b1
commit 579194dd35
6 changed files with 46 additions and 12 deletions

View File

@ -93,7 +93,7 @@ Item{
property real fontScaling: 1.0
property real fontWidth: 1.0
property var fontIndexes: [0,0,0]
property var fontNames: ["TERMINUS", "COMMODORE_PET", "COMMODORE_PET"]
property var fontlist: fontManager.item.fontlist
signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling, real fontWidth)
@ -116,6 +116,14 @@ Item{
onFontScalingChanged: handleFontChanged();
onFontWidthChanged: handleFontChanged();
function getIndexByName(name) {
for (var i = 0; i < fontlist.count; i++) {
if (name === fontlist.get(i).name)
return i;
}
return undefined;
}
function incrementScaling(){
fontScaling = Math.min(fontScaling + 0.05, 2.50);
handleFontChanged();
@ -127,8 +135,12 @@ Item{
}
function handleFontChanged(){
if(!fontManager.item) return;
fontManager.item.selectedFontIndex = fontIndexes[rasterization];
if (!fontManager.item) return;
var index = getIndexByName(fontNames[rasterization]);
if (index === undefined) return;
fontManager.item.selectedFontIndex = index;
fontManager.item.scaling = fontScaling * window_scaling;
var fontSource = fontManager.item.source;
@ -166,7 +178,7 @@ Item{
window_scaling: window_scaling,
show_terminal_size: show_terminal_size,
fontScaling: fontScaling,
fontIndexes: fontIndexes,
fontNames: fontNames,
frameReflections: _frameReflections,
showMenubar: showMenubar,
bloom_quality: bloom_quality,
@ -196,7 +208,7 @@ Item{
contrast: contrast,
ambient_light: ambient_light,
windowOpacity: windowOpacity,
fontIndex: fontIndexes[rasterization],
fontName: fontNames[rasterization],
fontWidth: fontWidth
}
return stringify(settings);
@ -237,7 +249,7 @@ Item{
fps = settings.fps !== undefined ? settings.fps: fps
window_scaling = settings.window_scaling !== undefined ? settings.window_scaling : window_scaling
fontIndexes = settings.fontIndexes !== undefined ? settings.fontIndexes : fontIndexes
fontNames = settings.fontNames !== undefined ? settings.fontNames : fontNames
fontScaling = settings.fontScaling !== undefined ? settings.fontScaling : fontScaling
_frameReflections = settings.frameReflections !== undefined ? settings.frameReflections : _frameReflections;
@ -278,7 +290,7 @@ Item{
brightness = settings.brightness !== undefined ? settings.brightness : brightness;
windowOpacity = settings.windowOpacity !== undefined ? settings.windowOpacity : windowOpacity;
fontIndexes[rasterization] = settings.fontIndex !== undefined ? settings.fontIndex : fontIndexes[rasterization];
fontNames[rasterization] = settings.fontName !== undefined ? settings.fontName : fontNames[rasterization];
fontWidth = settings.fontWidth !== undefined ? settings.fontWidth : fontWidth;
}

View File

@ -34,6 +34,7 @@ Item{
ListModel{
id: fontlist
ListElement{
name: "COMMODORE_PET"
text: "Commodore PET (1977)"
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
lineSpacing: 2
@ -42,6 +43,7 @@ Item{
fontWidth: 0.8
}
ListElement{
name: "APPLE_II"
text: "Apple ][ (1977)"
source: "fonts/1977-apple2/PrintChar21.ttf"
lineSpacing: 2
@ -50,6 +52,7 @@ Item{
fontWidth: 0.9
}
ListElement{
name: "ATARI_400"
text: "Atari 400-800 (1979)"
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
lineSpacing: 3
@ -58,6 +61,7 @@ Item{
fontWidth: 0.8
}
ListElement{
name: "COMMODORE_64"
text: "Commodore 64 (1982)"
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
lineSpacing: 3

View File

@ -34,6 +34,7 @@ Item{
ListModel{
id: fontlist
ListElement{
name: "COMMODORE_PET"
text: "Commodore PET (1977)"
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
lineSpacing: 2
@ -42,6 +43,7 @@ Item{
fontWidth: 0.7
}
ListElement{
name: "APPLE_II"
text: "Apple ][ (1977)"
source: "fonts/1977-apple2/PrintChar21.ttf"
lineSpacing: 2
@ -50,6 +52,7 @@ Item{
fontWidth: 0.8
}
ListElement{
name: "ATARI_400"
text: "Atari 400-800 (1979)"
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
lineSpacing: 3
@ -58,6 +61,7 @@ Item{
fontWidth: 0.7
}
ListElement{
name: "COMMODORE_64"
text: "Commodore 64 (1982)"
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
lineSpacing: 3

View File

@ -36,6 +36,7 @@ Item{
ListModel{
id: fontlist
ListElement{
name: "TERMINUS"
text: "Terminus (Modern)"
source: "fonts/modern-terminus/TerminusTTF-Bold-4.38.2.ttf"
lineSpacing: 0.2
@ -43,6 +44,7 @@ Item{
fontWidth: 1.0
}
ListElement{
name: "COMMODORE_PET"
text: "Commodore PET (1977)"
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
lineSpacing: 0.2
@ -50,6 +52,7 @@ Item{
fontWidth: 0.7
}
ListElement{
name: "APPLE_II"
text: "Apple ][ (1977)"
source: "fonts/1977-apple2/PrintChar21.ttf"
lineSpacing: 0.2
@ -57,6 +60,7 @@ Item{
fontWidth: 0.8
}
ListElement{
name: "ATARI_400"
text: "Atari 400-800 (1979)"
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
lineSpacing: 0.3
@ -64,6 +68,7 @@ Item{
fontWidth: 0.7
}
ListElement{
name: "COMMODORE_64"
text: "Commodore 64 (1982)"
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
lineSpacing: 0.3
@ -71,6 +76,7 @@ Item{
fontWidth: 0.7
}
ListElement{
name: "ATARI_ST"
text: "Atari ST (1985)"
source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf"
lineSpacing: 0.2
@ -78,6 +84,7 @@ Item{
fontWidth: 1.0
}
ListElement{
name: "IBM_DOS"
text: "IBM DOS (1985)"
source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf"
lineSpacing: 0.2
@ -85,6 +92,7 @@ Item{
fontWidth: 1.0
}
ListElement{
name: "IBM_3278"
text: "IBM 3278 (1971)"
source: "fonts/1971-ibm-3278/3270Medium.ttf"
lineSpacing: 0.2

View File

@ -36,7 +36,6 @@ Tab{
currentIndex: appSettings.rasterization
onCurrentIndexChanged: {
appSettings.rasterization = currentIndex
fontChanger.updateIndex();
}
}
}
@ -51,14 +50,22 @@ Tab{
id: fontChanger
Layout.fillWidth: true
model: appSettings.fontlist
currentIndex: updateIndex()
onActivated: {
appSettings.fontIndexes[appSettings.rasterization] = index;
var name = appSettings.fontlist.get(index).name;
appSettings.fontNames[appSettings.rasterization] = name;
appSettings.handleFontChanged();
}
function updateIndex(){
currentIndex = appSettings.fontIndexes[appSettings.rasterization];
var name = appSettings.fontNames[appSettings.rasterization];
var index = appSettings.getIndexByName(name);
if (index !== undefined)
currentIndex = index;
}
Connections{
target: appSettings
onRasterizationChanged: fontChanger.updateIndex();
}
Component.onCompleted: updateIndex();
}
Text{ text: qsTr("Scaling") }
RowLayout{

View File

@ -261,7 +261,6 @@ ShaderEffect {
(glowing_line_strength !== 0 ? "
color += randomPass(coords) * glowing_line_strength;" : "") +
"vec3 txt_color = texture2D(source, txt_coords).rgb;" +
(motion_blur !== 0 ? "