I've developed a script that acts as a console based application (think ncurses) using PowerShell.
The font Lucida Console is configured within a shortcut to the script.
I'd like to provide the user with the ability to change the font size. The following module does just that, however the font is always reset to 'Raster Fonts': https://4sysops.com/archives/change-powershell-console-font-size-with-cmdlet/
I don't understand why this happens, as the code appears to produce the list of legal font sizes based on a reference to the current font information.
@sodawillow's comment sent me on the right course. To elaborate...
It appears that list of valid font sizes is determined by the console window size (there may also be other factors that I have failed to consider).
For example, get-consolefontinfo | format-table returns the following on a window size of 120x64:
nFont dwFontSizeX dwFontSizeY
----- ----------- -----------
0 84 42
1 70 48
2 52 64
3 105 64
4 105 64
5 120 64
6 120 64
7 168 64
8 52 96
9 105 96
10 140 96
11 210 128
Whereas with a window size of 106x51, it returns:
nFont dwFontSizeX dwFontSizeY
----- ----------- -----------
0 104 49
1 114 49
2 125 49
3 104 55
4 78 73
5 156 73
6 179 73
7 250 73
8 78 110
9 156 110
10 209 110
11 313 147
The font (Consolas, Lucida Console or Raster Fonts) that's applied will differ depending on the index selected.
So contrary to my question, this module does not always reset the font to 'Raster Fonts'.
Set-ConsoleFont
function to work from the module at all. Is any of this working in 2022, and if not, does anyone have a way to do this (as I'm quite interested in getting this working)?