Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cwchar>
- #include <Windows.h>
- class localization {
- public:
- void saveWinConsoleFont() {
- GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &this->savedFont);
- }
- void changeWinConsoleFont(const wchar_t * wstr, SHORT size) {
- CONSOLE_FONT_INFOEX cfi;
- cfi.cbSize = sizeof(cfi);
- cfi.nFont = 0;
- cfi.dwFontSize.X = 0; // Width of each character in the font
- cfi.dwFontSize.Y = size;// Height
- cfi.FontFamily = FF_DONTCARE;
- cfi.FontWeight = FW_NORMAL;
- std::wcscpy(cfi.FaceName, wstr); // Choose your font
- SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
- }
- void restoreWinConsoleFont() {
- SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &this->savedFont);
- }
- private:
- CONSOLE_FONT_INFOEX savedFont;
- };
- int main() {
- localization loc;
- loc.saveWinConsoleFont();
- loc.changeWinConsoleFont(L"Consolas", 16);
- std::cout << "Hello World!" << std::endl;
- loc.restoreWinConsoleFont();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement