mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 15:12:28 +00:00 
			
		
		
		
	Merge pull request #197 from Swordfish90/add-pixelated-fonts
Add pixelated fonts and use them as default
This commit is contained in:
		| @@ -81,6 +81,8 @@ QtObject{ | ||||
|     property real fontScaling: 1.0 | ||||
|     property real fontWidth: 1.0 | ||||
|  | ||||
|     property bool lowResolutionFont: false | ||||
|  | ||||
|     property var fontNames: ["HERMIT", "COMMODORE_PET", "COMMODORE_PET"] | ||||
|     property var fontlist: fontManager.item.fontlist | ||||
|  | ||||
| @@ -135,6 +137,8 @@ QtObject{ | ||||
|         var screenScaling = fontManager.item.screenScaling; | ||||
|         var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth; | ||||
|  | ||||
|         lowResolutionFont = fontManager.item.lowResolutionFont; | ||||
|  | ||||
|         terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth); | ||||
|     } | ||||
|  | ||||
| @@ -367,12 +371,12 @@ QtObject{ | ||||
|     property ListModel profilesList: ListModel{ | ||||
|         ListElement{ | ||||
|             text: "Default Amber" | ||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.65,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"HERMIT","fontColor":"#ff8100","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.4,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.65,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#ff8100","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.4,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             builtin: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             text: "Default Green" | ||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"HERMIT","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.45,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.45,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             builtin: true | ||||
|         } | ||||
|         ListElement{ | ||||
| @@ -407,7 +411,7 @@ QtObject{ | ||||
|         } | ||||
|         ListElement{ | ||||
|             text: "Transparent Green" | ||||
|             obj_string: '{"ambientLight":0.2,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"flickering":0.20,"contrast":0.85,"fontName":"HERMIT","fontColor":"#0ccc68","frameName":"NO_FRAME","glowingLine":0.16,"horizontalSync":0.1,"jitter":0.20,"burnIn":0.25,"staticNoise":0.20,"rasterization":0,"screenCurvature":0.05,"windowOpacity":0.60,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             obj_string: '{"ambientLight":0.2,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"flickering":0.20,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"NO_FRAME","glowingLine":0.16,"horizontalSync":0.1,"jitter":0.20,"burnIn":0.25,"staticNoise":0.20,"rasterization":0,"screenCurvature":0.05,"windowOpacity":0.60,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||
|             builtin: true | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -29,6 +29,7 @@ QtObject{ | ||||
|     property int lineSpacing: _font.lineSpacing | ||||
|     property real screenScaling: scaling * _font.baseScaling | ||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||
|     property bool lowResolutionFont: true | ||||
|  | ||||
|     property ListModel fontlist: ListModel{ | ||||
|         ListElement{ | ||||
| @@ -49,6 +50,24 @@ QtObject{ | ||||
|             baseScaling: 4.0 | ||||
|             fontWidth: 0.9 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "TERMINUS_SCALED" | ||||
|             text: "Terminus (Modern)" | ||||
|             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "PRO_FONT_SCALED" | ||||
|             text: "Pro Font (Modern)" | ||||
|             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "APPLE_II" | ||||
|             text: "Apple ][ (1977)" | ||||
|   | ||||
| @@ -29,6 +29,7 @@ QtObject{ | ||||
|     property int lineSpacing: _font.lineSpacing | ||||
|     property real screenScaling: scaling * _font.baseScaling | ||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||
|     property bool lowResolutionFont: true | ||||
|  | ||||
|     property ListModel fontlist: ListModel{ | ||||
|         ListElement{ | ||||
| @@ -49,6 +50,24 @@ QtObject{ | ||||
|             baseScaling: 4.0 | ||||
|             fontWidth: 0.9 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "TERMINUS_SCALED" | ||||
|             text: "Terminus (Modern)" | ||||
|             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "PRO_FONT_SCALED" | ||||
|             text: "Pro Font (Modern)" | ||||
|             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "APPLE_II" | ||||
|             text: "Apple ][ (1977)" | ||||
|   | ||||
| @@ -25,117 +25,183 @@ QtObject{ | ||||
|     property real scaling | ||||
|     property var source: fontlist.get(selectedFontIndex).source | ||||
|     property var _font: fontlist.get(selectedFontIndex) | ||||
|     property int pixelSize: _font.pixelSize * scaling | ||||
|     property int lineSpacing: pixelSize * _font.lineSpacing | ||||
|     property real screenScaling: 1.0 | ||||
|     property bool lowResolutionFont: _font.lowResolutionFont | ||||
|  | ||||
|     property int pixelSize: lowResolutionFont | ||||
|                                  ? _font.pixelSize | ||||
|                                  : _font.pixelSize * scaling | ||||
|  | ||||
|     property int lineSpacing: lowResolutionFont | ||||
|                                   ? _font.lineSpacing | ||||
|                                   : pixelSize * _font.lineSpacing | ||||
|  | ||||
|     property real screenScaling: lowResolutionFont | ||||
|                                      ? _font.baseScaling * scaling | ||||
|                                      : 1.0 | ||||
|  | ||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||
|  | ||||
|     //In this configuration lineSpacing is proportional to pixelSize. | ||||
|     // 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 | ||||
|     // to fill the screen (they are much faster to render). | ||||
|     // High resolution fonts are instead drawn on a texture which has the | ||||
|     // 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{ | ||||
|         ListElement{ | ||||
|             name: "HERMIT" | ||||
|             text: "Hermit (Modern)" | ||||
|             source: "fonts/modern-hermit/Hermit-medium.otf" | ||||
|             lineSpacing: 0.05 | ||||
|             pixelSize: 28 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "TERMINUS" | ||||
|             name: "TERMINUS_SCALED" | ||||
|             text: "Terminus (Modern)" | ||||
|             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "ENVY_CODE_R" | ||||
|             text: "Envy Code R (Modern)" | ||||
|             source: "fonts/modern-envy-code-r/Envy Code R.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 30 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "PRO_FONT" | ||||
|             name: "PRO_FONT_SCALED" | ||||
|             text: "Pro Font (Modern)" | ||||
|             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 12 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "MONACO" | ||||
|             text: "Monaco (Modern)" | ||||
|             source: "fonts/modern-monaco/monaco.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 30 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "INCONSOLATA" | ||||
|             text: "Inconsolata (Modern)" | ||||
|             source: "fonts/modern-inconsolata/Inconsolata.otf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             fontWidth: 1.0 | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "COMMODORE_PET" | ||||
|             name: "COMMODORE_PET_SCALED" | ||||
|             text: "Commodore PET (1977)" | ||||
|             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" | ||||
|             lineSpacing: 0.2 | ||||
|             pixelSize: 26 | ||||
|             lineSpacing: 2 | ||||
|             pixelSize: 8 | ||||
|             baseScaling: 3.5 | ||||
|             fontWidth: 0.7 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "APPLE_II" | ||||
|             name: "PROGGY_TINY_SCALED" | ||||
|             text: "Proggy Tiny (Modern)" | ||||
|             source: "fonts/modern-proggy-tiny/ProggyTiny.ttf" | ||||
|             lineSpacing: 1 | ||||
|             pixelSize: 16 | ||||
|             baseScaling: 3.0 | ||||
|             fontWidth: 0.9 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "APPLE_II_SCALED" | ||||
|             text: "Apple ][ (1977)" | ||||
|             source: "fonts/1977-apple2/PrintChar21.ttf" | ||||
|             lineSpacing: 0.2 | ||||
|             pixelSize: 26 | ||||
|             lineSpacing: 2 | ||||
|             pixelSize: 8 | ||||
|             baseScaling: 3.5 | ||||
|             fontWidth: 0.8 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "ATARI_400" | ||||
|             name: "ATARI_400_SCALED" | ||||
|             text: "Atari 400-800 (1979)" | ||||
|             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" | ||||
|             lineSpacing: 0.3 | ||||
|             pixelSize: 26 | ||||
|             lineSpacing: 3 | ||||
|             pixelSize: 8 | ||||
|             baseScaling: 3.5 | ||||
|             fontWidth: 0.7 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "COMMODORE_64" | ||||
|             name: "COMMODORE_64_SCALED" | ||||
|             text: "Commodore 64 (1982)" | ||||
|             source: "fonts/1982-commodore64/C64_Pro_Mono_v1.0-STYLE.ttf" | ||||
|             lineSpacing: 0.3 | ||||
|             pixelSize: 26 | ||||
|             lineSpacing: 3 | ||||
|             pixelSize: 8 | ||||
|             baseScaling: 3.5 | ||||
|             fontWidth: 0.7 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "ATARI_ST" | ||||
|             name: "ATARI_ST_SCALED" | ||||
|             text: "Atari ST (1985)" | ||||
|             source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf" | ||||
|             lineSpacing: 0.2 | ||||
|             pixelSize: 32 | ||||
|             lineSpacing: 3 | ||||
|             pixelSize: 16 | ||||
|             baseScaling: 2.0 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "IBM_DOS" | ||||
|             text: "IBM DOS (1985)" | ||||
|             source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437 Win.ttf" | ||||
|             lineSpacing: 0.2 | ||||
|             pixelSize: 32 | ||||
|             lineSpacing: 3 | ||||
|             pixelSize: 16 | ||||
|             baseScaling: 2.0 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: true | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "HERMIT" | ||||
|             text: "HD: Hermit (Modern)" | ||||
|             source: "fonts/modern-hermit/Hermit-medium.otf" | ||||
|             lineSpacing: 0.05 | ||||
|             pixelSize: 28 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "TERMINUS" | ||||
|             text: "HD: Terminus (Modern)" | ||||
|             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "PRO_FONT" | ||||
|             text: "HD: Pro Font (Modern)" | ||||
|             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "ENVY_CODE_R" | ||||
|             text: "HD: Envy Code R (Modern)" | ||||
|             source: "fonts/modern-envy-code-r/Envy Code R.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 30 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "MONACO" | ||||
|             text: "HD: Monaco (Modern)" | ||||
|             source: "fonts/modern-monaco/monaco.ttf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 30 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "INCONSOLATA" | ||||
|             text: "HD: Inconsolata (Modern)" | ||||
|             source: "fonts/modern-inconsolata/Inconsolata.otf" | ||||
|             lineSpacing: 0.1 | ||||
|             pixelSize: 35 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|         ListElement{ | ||||
|             name: "IBM_3278" | ||||
|             text: "IBM 3278 (1971)" | ||||
|             text: "HD: IBM 3278 (1971)" | ||||
|             source: "fonts/1971-ibm-3278/3270Medium.ttf" | ||||
|             lineSpacing: 0.2 | ||||
|             pixelSize: 32 | ||||
|             fontWidth: 1.0 | ||||
|             lowResolutionFont: false | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -83,7 +83,7 @@ Item{ | ||||
|  | ||||
|         colorScheme: "cool-retro-term" | ||||
|  | ||||
|         smooth: appSettings.rasterization === appSettings.no_rasterization | ||||
|         smooth: !appSettings.lowResolutionFont | ||||
|         enableBold: false | ||||
|         fullCursorHeight: true | ||||
|  | ||||
| @@ -115,13 +115,13 @@ Item{ | ||||
|         function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth){ | ||||
|             fontLoader.source = fontSource; | ||||
|  | ||||
|             kterminal.antialiasText = appSettings.rasterization === appSettings.no_rasterization | ||||
|             kterminal.antialiasText = !appSettings.lowResolutionFont; | ||||
|             font.pixelSize = pixelSize; | ||||
|             font.family = fontLoader.name; | ||||
|  | ||||
|             terminalContainer.fontWidth = fontWidth; | ||||
|             terminalContainer.screenScaling = screenScaling; | ||||
|             scaleTexture = Math.max(1.0, Math.round(screenScaling / 2)); | ||||
|             scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling)); | ||||
|  | ||||
|             kterminal.lineSpacing = lineSpacing; | ||||
|         } | ||||
| @@ -271,8 +271,15 @@ Item{ | ||||
|     Loader{ | ||||
|         id: blurredTerminalLoader | ||||
|  | ||||
|         width: kterminal.width * scaleTexture * appSettings.burnInQuality | ||||
|         height: kterminal.height * scaleTexture * appSettings.burnInQuality | ||||
|         property int burnInScaling: scaleTexture * appSettings.burnInQuality | ||||
|  | ||||
|         width: appSettings.lowResolutionFont | ||||
|                   ? kterminal.width * Math.max(1, burnInScaling) | ||||
|                   : kterminal.width * scaleTexture * appSettings.burnInQuality | ||||
|         height: appSettings.lowResolutionFont | ||||
|                     ? kterminal.height * Math.max(1, burnInScaling) | ||||
|                     : kterminal.height * scaleTexture * appSettings.burnInQuality | ||||
|  | ||||
|         active: mBlur !== 0 | ||||
|         asynchronous: true | ||||
|  | ||||
|   | ||||
| @@ -67,8 +67,8 @@ ShaderTerminal{ | ||||
|     bloomSource: bloomSourceLoader.item | ||||
|  | ||||
|     // This shader might be useful in the future. Since we used it only for a couple | ||||
|     // of calculations is probably best to move those in the main shader. If in | ||||
|     // we will need to store another fullScreen channel this might be handy. | ||||
|     // of calculations is probably best to move those in the main shader. If in the future | ||||
|     // we need to store another fullScreen channel this might be handy. | ||||
|  | ||||
| //    ShaderEffect { | ||||
| //        id: rasterizationEffect | ||||
|   | ||||
		Reference in New Issue
	
	Block a user