C++ Console : Change Font Size
Font size is not a very big deal but i had to post it's code here because we'll be using it to change the fonts of our console in such ratio that will help us making geometric shapes like squares, easily and perfectly. Here is a list of available ratios that a console supports. You can use either of them:
- 4:6
- 6:8
- 8:8
- 16:8
- 5:12
- 7:12
- 16:12
- 12:16
- 10:18
#include <iostream>
#include <Windows.h>
using namespace std;
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
void fontsize(int,int);
void main(){
fontsize(8, 8);
cout << "This is a symmetrical font" << endl;
system("pause");
}
void fontsize(int a, int b){
PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx = new CONSOLE_FONT_INFOEX();
lpConsoleCurrentFontEx->cbSize = sizeof(CONSOLE_FONT_INFOEX);
GetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
lpConsoleCurrentFontEx->dwFontSize.X = a;
lpConsoleCurrentFontEx->dwFontSize.Y = b;
SetCurrentConsoleFontEx(out, 0, lpConsoleCurrentFontEx);
}
Great, thank you!
ReplyDeleteyou forget to delete PConsole_FONT_INFOEX pointer
ReplyDelete