I tried the values you used -- {10, 10}, 600, FF_ROMAN -- and it silently failed for me, too. But I got other value to work ok (see below)
SetCurrentConsoleFontEx's habit of silently failing does seem to be a common complaint about this function. And even worse, there is no official way (i.e. in MSDN) to get the list of supported fonts. But there are unsupported API calls: GetConsoleFontInfo and GetNumberOfConsoleFonts [1]
Note hat your posted code :
- is not initializing unused struct members to zero
- is not defining the font index or face name
- is using hStdin for the get call: both should use hStdOut
I got SetCurrentConsoleFontEx to work with
1 2 3 4 5 6 7 8 9 10
|
COORD FontSize = {16, 12};
CONSOLE_FONT_INFOEX current = {0}; // zero all members
current.cbSize = sizeof(CONSOLE_FONT_INFOEX);
current.nFont = 11; // apparently this is Lucida Console (no consts are provided [3])
current.dwFontSize = FontSize;
current.FontWeight = FW_NORMAL; // = 400, but should use predefined consts
current.FontFamily = FF_DONTCARE; // FF_ROMAN didn't work for me
// FaceName is unused
|
If you just want to update the font size, you could reuse the info, just altering the size between the get and set calls (to hStdOut)
Andy
[1] Changing Console Fonts
http://blogs.microsoft.co.il/blogs/pavely/archive/2009/07/23/changing-console-fonts.aspx
[2] These two threads might also be of interest:
Console font size command
http://www.cplusplus.com/forum/beginner/28014/
Set font text in console application
http://social.msdn.microsoft.com/Forums/fi-FI/vclanguage/thread/2bffea84-e5a0-4fde-bd24-53cbcf1e3025