Larger font in larger output console window
Larger font in larger output console window
If I use the Width command to increase the columns and rows, it increases the output window size but the font size remains the same.
If I use the Screen or ScreenRes command, it creates a larger window but the font size remains the same and the larger window is opened as a second window.
How can I set a larger font in a larger output console window (with no second window opening)?
Thanks to anyone who can help me out.
If I use the Screen or ScreenRes command, it creates a larger window but the font size remains the same and the larger window is opened as a second window.
How can I set a larger font in a larger output console window (with no second window opening)?
Thanks to anyone who can help me out.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Larger font in larger output console window
You have no control over the text size in the console. At least not without jumping through some pretty nasty hoops..
The graphics window has character sets 8 pixels wide, and 8/14/16 pixels high. You can set this using Width.
KeyPgWidth
You can also use Draw String with a custom character sets of any size.
KeyPgDrawstring
Some people have produced code to turn fonts into FB character sets. I don't remember where, but you can try searching the forum or waiting for someone more familiar with this than I am to post a relevant link here.
The graphics window has character sets 8 pixels wide, and 8/14/16 pixels high. You can set this using Width.
KeyPgWidth
You can also use Draw String with a custom character sets of any size.
KeyPgDrawstring
Some people have produced code to turn fonts into FB character sets. I don't remember where, but you can try searching the forum or waiting for someone more familiar with this than I am to post a relevant link here.
Re: Larger font in larger output console window
Hi,
http://www.freebasic-portal.de/code-bei ... n-232.html
http://www.freebasic-portal.de/code-bei ... n-232.html
Code: Select all
#Include Once "windows.bi"
'ab Windows Vista
Const FF_LUCIDA = 54
'Const FF_TERMINAL = 48
Type CONSOLE_FONT_INFOEX
cbSize As UInteger
nFont As Integer
dwFontSize As COORD
FontFamily As UInteger
FontWeight As UInteger
FaceName As WString * LF_FACESIZE
End Type
Declare Function SetConsoleFont(ByVal sTypeface As String, wFontWidth As Short, wFontHeight As Short, wFontStyle As Short) As Integer
Dim Shared As Any Ptr Kernel32
Dim Shared GetCurrentConsoleFontEx As Function (ByVal hConsoleOutput As HANDLE _
, ByVal bMaximumWindow As Integer _
, ByVal lpConsoleCurrentFontEx As Any Ptr) As Integer
Dim Shared SetCurrentConsoleFontEx As Function (ByVal hConsoleOutput As HANDLE _
, ByVal bMaximumWindow As Integer _
, lpConsoleCurrentFontEx As Any Ptr) As Integer
Kernel32 = DylibLoad( "Kernel32.dll" )
If Kernel32 Then
GetCurrentConsoleFontEx = DylibSymbol( Kernel32, "GetCurrentConsoleFontEx" )
SetCurrentConsoleFontEx = DylibSymbol( Kernel32, "SetCurrentConsoleFontEx" )
Else
End
EndIf
Dim As Integer dwMxScrn = SetConsoleFont("Lucida Console", 10, 50, FF_LUCIDA)
If dwMxScrn Then
Print "Konsole mit " & LoWord(dwMxScrn) & "x" & HiWord(dwMxScrn) & " Zeichen."
Print "Test"
End If
DylibFree Kernel32
Sleep
Function SetConsoleFont(ByVal sTypeface As String,wFontWidth As Short _
, wFontHeight As Short, wFontStyle As Short) As Integer
Dim hConHdl As HANDLE = GetStdHandle(STD_OUTPUT_HANDLE)
If hConHdl < 0 Then Return 0
Dim ConFont As CONSOLE_FONT_INFOEX
With ConFont
.cbSize = SizeOf(ConFont)
.nFont = 0
.FontFamily = wFontStyle
.dwFontSize.X = wFontWidth
.dwFontSize.Y = wFontHeight
.FaceName = sTypeface
End With
If SetCurrentConsoleFontEx(hConHdl, 1, @ConFont) Then
GetCurrentConsoleFontEx(hConHdl, 1, @ConFont)
Function = ConFont.dwFontSize.X Shl(16) + ConFont.dwFontSize.Y
End If
End Function
Re: Larger font in larger output console window
I do not understand the code posted by I3I2UI/I0 but I tried it and when I execute the compiled code, Windows immediately says it encountered a problem and closes the window.
I just remembered that when the console windows is open, if I right-click on the title bar and change the font size from 8x12 to 10x18 and select "save properties for future windows with same title", then that compiled program always opens in the larger size I want. I would have preferred if I could have built that font size into the program so if I gave the program to somebody, it would open with the larger font without having to adjust it once manually.
I just remembered that when the console windows is open, if I right-click on the title bar and change the font size from 8x12 to 10x18 and select "save properties for future windows with same title", then that compiled program always opens in the larger size I want. I would have preferred if I could have built that font size into the program so if I gave the program to somebody, it would open with the larger font without having to adjust it once manually.
Last edited by bkoopers on Mar 24, 2013 21:08, edited 1 time in total.
Re: Larger font in larger output console window
I recall some years ago modifying the registry to indirectly control the console font size, but ATM I can’t find my code. I recall testing with the Lucida Console font, changing the font size in the console properties, observing what changes this made in the registry, and then trying to create code to change the registry directly. I think I managed to make it work somewhat, but I also seem to recall some limitation that I could not work around.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Larger font in larger output console window
Perhaps the simplest solution might be to run the app in a graphics screen, and scale up the results, either manually or possibly running in full screen mode.
My personal feeling is that people won't thank you for messing with their console settings.
My personal feeling is that people won't thank you for messing with their console settings.
Re: Larger font in larger output console window
I think the changes can be restricted to the console for a single instance of an application, but if an application made any sort of global change in my console settings it would do so only once.counting_pine wrote:My personal feeling is that people won't thank you for messing with their console settings.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Larger font in larger output console window
Even so, I dislike presumptions like: "you don't want my console app to look like a normal console app", or "you don't want to multitask my app with anything else, and you won't mind me going full-screen and changing your screen resolution without asking".
Or the old favourite, "you'd be much happier with your global volume control ramped up to 100%"
I digress slightly, but I still think a console app should look like a console app.
But at bare minimum, if I run it from the command line, any changes it makes to the console should all be undone by the time I get my prompt back.
Or the old favourite, "you'd be much happier with your global volume control ramped up to 100%"
I digress slightly, but I still think a console app should look like a console app.
But at bare minimum, if I run it from the command line, any changes it makes to the console should all be undone by the time I get my prompt back.
Re: Larger font in larger output console window
counting_pine: In general I agree with you, but in my case, I am converting a program to FreeBASIC that I use in a baseball simulation league that I run and it is only used by the 30 managers in the league (mostly people of older age whose eyesight is not what it used to be). I know all the end users and know that they would prefer the window to be a little bigger than the default size.
Re: Larger font in larger output console window
It only works with Windows Vista and above.bkoopers wrote:I do not understand the code posted by I3I2UI/I0 but I tried it and when I execute the compiled code, Windows immediately says it encountered a problem and closes the window.
In general, you might really consider using a graphics window using ScreenRes and scaling the font up to the size you like, or using one of the font libraries to draw text in a completely custom font (e.g. XFont)