Working with the limitations of CmdFont
Posted: 24 Nov 2017 00:45
The most recent incarnation of this utility was
I am OK with the set function only supporting Raster fonts, but I like the information provided with the get function and wanted to exploit it in a batch script. It it even displays limited information for non-raster fonts.
In the meantime, I used Antonio's Window.exe Auxiliary program to produce but I still don't know how to find the name of the current font. Even this falls short. My eyes have long since been unable to read a 4x6 font to see the result. I'll even argue that the font did not get small by itself, so, if I set it, I don't need to display it, but . . .
The front-end of the script that displayed the dimensions is:I am still packaging the back-end that creates a pop-up that is readable and does not disturb the original window.
John A.
on behalf of penpen.posted wrote:Rem Start http://www.dostips.com/forum/viewtopic. ... 820#p53820
Rem Posted: Wed Sep 06, 2017 11:50 am by aGerman
Rem Post subject: Automated setup of DOS command window
I am OK with the set function only supporting Raster fonts, but I like the information provided with the get function and wanted to exploit it in a batch script. It it even displays limited information for non-raster fonts.
I can see it but do not seem to be able to access it in batch. The output won't pipe and redirects to an empty file. Would this be because of the language used to write it or the method used for the display? Is there some way to work around this?Sample Output wrote:0::Terminal::4x6
1::Terminal::6x8
2::Terminal::8x8
3::Terminal::16x8
4::Terminal::5x12
5::Terminal::7x12
6::Terminal::8x12
7::Terminal::16x12
8::Terminal::12x16
9::Terminal::10x18
-::Consolas::20::CURRENT
In the meantime, I used Antonio's Window.exe Auxiliary program to produce
Code: Select all
C:\Users\Zyltch\~Scripts~>fontdims 0
'Illegible' input argument '0' overrides default to 0 value.
0::Terminal::4x6
1::Terminal::6x8
2::Terminal::8x8
3::Terminal::16x8
4::Terminal::5x12
5::Terminal::7x12
6::Terminal::8x12
7::Terminal::16x12
8::Terminal::12x16
9::Terminal::10x18
-::Consolas::20::CURRENT
Font Size: (9 x 20) pixels.
The front-end of the script that displayed the dimensions is:
Code: Select all
@echo off &setlocal EnableDelayedExpansion
:: Forked from FontSizes.bat: Wed Oct 17, 2017
Rem Adjust Illegible value to suit screen size and resolution
Rem and optical acuity of the user: [Ease-of-Use if not eagle-eyed]
Set "Illegible=%~1"
If Defined Illegible (
Set /A "Illegible=%~1"
Echo.&Echo.'Illegible' input argument '%~1' overrides default to !Illegible! value.
) Else Set /A "Illegible=0"
Rem Default value: 0 - Value of 0 is to bypass readable pop-up.
Rem Suggested value: 7 - Value greater than 19 activates pop-up in most cases.
Rem Non-critical external batch executable dependency is available at
Rem Start http://www.dostips.com/forum/viewtopic.php?p=53820#p53820
Rem Posted: Wed Sep 06, 2017 11:50 am by aGerman
Rem Post subject: Automated setup of DOS command window
Call cmdfont get
Rem Critical external batch executable dependency
ver>Nul
Where window.exe>nul 2>nul
If ERRORLEVEL 1 (Echo.
Echo.Window.exe is critical to this batch script and is available at
Echo.Start http://www.dostips.com/forum/viewtopic.php?f=3^&t=3428
Exit /B
)
Rem Start http://www.dostips.com/forum/viewtopic.php?f=3&t=3428
Window Size
Call :UnsignedCoords %ErrorLevel% WinSizeH WinSizeV
Window GSize
Call :UnsignedCoords %ErrorLevel% GsizeH GsizeV
Rem Do the math for active font dimensions
Set /A "FontH=GsizeH/WinSizeH, FontV=GsizeV/WinSizeV"
Rem No need to continue if the results are legible in the current font
If %fontV% GTR %Illegible% (Echo.
Echo.Font Size: ^(%FontH% x %FontV%^) pixels.
Exit /B
) Else GoTo :More-readable
Rem The only Subroutine required above is sheltered after the GOTO
Rem This cloned batch subroutine separates into two 16-bits numbers
Rem the 32-bits value returned by some Registry queries and Aux programs
:UnsignedCoords 32bits Horizontal= Vertical=
Set /A "%2=%1&0xFFFF, %3=(%1>>16)&0xFFFF"
Exit /B
Rem Start https://stackoverflow.com/a/19188162/1012053
Rem _ _ _ _ _
Rem /_\ | | | | __| | ___ _,_ ___ | |
Rem / _ \ | | | | / _ | / _ \ | \ / -_) |_|
Rem /_/ \_\ |_| |_| \__,_| \___/ |_||_| \___) (_)
Rem
Rem This batch script can be complete at this point.
Rem If the output is not readable,
Rem it may be viewed by temporarily adjusting to a
Rem larger font size using Window Properties or other means.
Rem The following code may also show the results, but will never be
Rem reached if the Illegible value is adjusted to a very low value
:More-readable
John A.