Hi CajunCoder, I had had the same problem as you, but I've found a solution.
(I use Code::Blocks 16.01 (mingw), windows 8.1)
I am going to provide you 2 ways of solving it:
1. Just as you showed in the program, using code:
(Also, good call with the _WIN32_WINNT)
For some reason you have to define the structure inside your program and declare the SetConsoleFont as shown below (using all 7 lines).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#define _WIN32_WINNT 0x0601
#include<windows.h>
typedef struct _CONSOLE_FONT_INFOEX
{
ULONG cbSize;
DWORD nFont;
COORD dwFontSize;
UINT FontFamily;
UINT FontWeight;
WCHAR FaceName[LF_FACESIZE];
}CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
//the function declaration begins
#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI SetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX
lpConsoleCurrentFontEx);
#ifdef __cplusplus
}
#endif
//the function declaration ends
int main()
{
int
newWidth=8,
newHeight=8;
CONSOLE_FONT_INFOEX fontStructure={0};
fontStructure.cbSize=sizeof(fontStructure);
fontStructure.dwFontSize.X=newWidth;
fontStructure.dwFontSize.Y=newHeight;
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
SetCurrentConsoleFontEx(hConsole, true, &fontStructure);
system("pause");
}
|
Try it and see if magic happens.
2. Manually change the font (which is maybe useless for what you intend to do, as I've also wanted to change the font in real time, and you might probably know this by now):
-Compile the program and open the executable.
-Right-Click the Title Bar.
-Click "Properties".
-When the properties windows pops, it might be in the options tab (if you've never switched to another tab here), so go to the font tab.
-Here you can change the font style and sizes (I use the Raster font, with the 8x8 size to be able to create various shapes and even retro video games physics).