Sign in to follow this  

Programatically Getting Win32 Console Font?

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a project I'm working on, I need to be able to get font data for the font used in a console window (so that I can either draw the font or get it as a bitmap some other way). There is a function called GetCurrentConsoleFont that gets you the "Index of the font in the system's console font table", but I have no idea how to use that index to get a drawable font. I've googled the web and groups and I can't find any way to get the font info I need. If you know anything about it, I'd greatly appreciate the help. Also, if there is a way to make a win32 console program go fullscreen programatically I could use that info as well (only way I know of is using sendinput and that isn't a sure way of doing it).

Share this post


Link to post
Share on other sites
I dont know about the font but these are the functions I used to create a fullscreen console


bool Console::MakeFullscreen() {
if (!allocated)
return false;

//We'll grab the largest size
COORD c = GetLargestWindowSize();

//The make the console that size
if (!SetSize(c))
return false;

#if _WIN32_WINNT >= 0x0500
//If the OS is right we'll also try to maximize the actual window
HWND hwnd = ::GetConsoleWindow();

if (!::ShowWindow(hwnd, SW_MAXIMIZE))
return false;
#endif

return true;
}

bool Console::SetSize(const COORD s) {
if (!allocated)
return false;

//Copy the new size into our handy member size for later use
size = s;

//Set the screen buffer size first since Win32 is picky that the screen buffer is
//never smaller than the console window
if (!::SetConsoleScreenBufferSize(Primary, size))
return false;

BackBuf.resize(size.X * size.Y);

//Fill the back buffer with some empty data
CHAR_INFO ci = {0, 15};
std::fill(BackBuf.begin(), BackBuf.end(), ci);

SMALL_RECT sr;

sr.Left = 0;
sr.Top = 0;

//SetConsoleWindowInfo() requires that the maximum size is width - 1, height - 1
sr.Right = size.X - 1;
sr.Bottom = size.Y - 1;

if (!SetWindowInfo(TRUE, &sr))
return false;

return true;
}


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Maybe I'm misunderstanding your code, but it seems to make the console window large meaning lots of character cells. I want to keep the resolution I have (80*50), but make that take the full screen, like it does when you press alt-enter with my application's window on top.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I want to keep the resolution I have (80*50), but make that take the full screen, like it does when you press alt-enter with my application's window on top.
SetConsoleDisplayMode.

Couple seconds with Google/MSDN. Seize the initiative. Cool runnings.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Quote:
Original post by Anonymous Poster
I want to keep the resolution I have (80*50), but make that take the full screen, like it does when you press alt-enter with my application's window on top.
SetConsoleDisplayMode.

Couple seconds with Google/MSDN. Seize the initiative. Cool runnings.
Hrmm, XP only(And thus not in my local copy of the MSDN) =-(
It needs to run in 2000 also, but I guess I can just try a GetProcAddress call and if it fails they'll have to set it themselves

Any idea on the font information? The full screen thing was just an aside and I hadn't googled it much at all, but I did extensively google the console font thing and I haven't found anything on it.

Share this post


Link to post
Share on other sites

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this