I call GetCurrentConsoleFontEx
and then call SetCurrentConsoleFontEx
with the same information. I would have expected that setting the new_font = old_font
would have no effect.
Clearly, I was naive.
The exact program is:
#define _WIN32_WINNT 0x0502
#include <Windows.h>
int main()
{
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX cfi1, cfi2;
cfi1.cbSize = sizeof(cfi1);
cfi2.cbSize = sizeof(cfi2);
if (0 == GetCurrentConsoleFontEx(out, false, &cfi1))
return -1;
if (0 == SetCurrentConsoleFontEx(out, false, &cfi1))
return -1;
if (0 == GetCurrentConsoleFontEx(out, false, &cfi2))
return -1;
return 0;
}
The program exits with code 0
, so the API calls didn't fail.
From cfi1
to cfi2
, the value of nFont
, an index into a table of fonts, changed from 1
to 3
. The size of the font's width and height, dwFontSize
, changed from {12, 25}
to {15, 31}
.
Why is this happening?
EDIT: Calling GetConsoleFontSize
when the second parameter for the calls is false
returns the same font size as GetCurrentConsoleFontEx
. When the second parameter is true
, GetConsoleFontSize
returns {12, 15}
before and {23, 49}
after. GetCurrentConsoleFontEx
reports the font size to be {80, 20}
both times. nFont
still changes.