Originally posted by: Scott
Thanks Roger. I teach C++ at a technical college and am always looking for interesting snippets to fire up my class. They'll love this one. Thanks!
ReplyOriginally posted by: CLM
(the following does apply to the serious Windows versions only, that is: not win95/98/me)
Has anyone yet figured out how to programmatically set the font used in the console window?
To use either Unicode applications or applications displaying text in the ANSI codepage you'll have to change the console window's code page to something appropriate.
(normally, it's 437 or something similar, this being the IBM PC-compatible character set).
Using SetConsoleOutputCP and SetConsoleCP this is no great problem ...
alas, the default bitmap font used in console windows (a *.fon font) is not abled to display anything else but the codepage it has been created for.
To get a correct display, it's necessary to use the Lucida Console font (which is a nice Unicode font BTW).
Hence my need to change the font used in console windows.
It is possible to set this system-wide or for single applications using either the control panel applet (in NT4.0) or the console window's system menu's settings functionality. This results in some registry settings under HKCU\Console (for 'standard settings') or in a subkey thereof (for individual settings), titled like the shortcut used to create the console window.
What if the console window isn't created by a shortcut, but by an application?
Now, I haven't found a way to change this programmatically.
Another thing that baffles me is the inconherent behaviour of NT 4 and Windows 2000 in handling console fonts.
The font Andale Mono (previously known as Monotype.com) can be used as a console windows font under Windows NT 4.0. On Windows 2000 this font disappears from the console font settings dialogue.
Using Andale Mono instead of Lucida Console is nice, since Andale Mono displays clearly distinguishable glyphs for the characters 0 and O (zero and 'Oh') and 1 I l (one, uppercase I and lowercase L) at every point size.
ReplyOriginally posted by: Jey
Thanks, good job!
This has just saved me whole bunch of time, I've been looking for something like this...