I started work on a simple console based game, the game is basically Oregon Trail with ASCII graphics with a post apocalyptic twist. Everything is working well, I also attempted to add some detail using ASCII & Unicode. This is inspired by the first computer games I played on a Atnt 6300 PC. They were very basic games... (pun intended)
What I want to do is further extend the graphics by including my own fonts, but instead using them to draw sprite characters. The console is limited to using files with the ".fon" extension so after a long search I found a program that can edit/create new fonts in this format.
After much trial and error I have the "highway" sprite using 8x12 pixels correctly loaded into the Windows font folder and showing correctly in the Char map, indexed as 0x54.
Now this is were I'm stuck. Pure Basic still copies in a "T" instead of my new font. Pure Basic and the console have no idea how to load or use my new font. I was wondering if I could invoke such a change by using the Win32 api? But I have no idea how to do this. Of course I could simply edit the "terminal" font but since this is a Windows font used by the OS it could be dangerous make system changes like this. Another solution would be to create the game within a gui window and instead mimic the entire look and feel of console using True type fonts, but it would ruin some of the nostalgic appeal to me, I really want to make a console only game.
I've looked up a few C++ examples I think could solve my issue but again I have no idea how to implement them. Any advice would be appreciated!
https://stackoverflow.com/questions/353 ... -font-size
Maybe worth noting that SetCurrentConsoleFontEx requires Vista or later ( _WIN32_WINNT >= 0x0500). Also, the documentation is not clear on how exactly cfi.nFont = 0; works ("nFont = The index of the font in the system's console font table.")
Code: Select all
// THIS IS C++
#include <cwchar>
#include <windows.h>
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 = 24; // Height
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
std::wcscpy(cfi.FaceName, L"Consolas"); // Choose your font
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
std::cout << "Font: Consolas, Size: 24\n";