Jump to content
  • Advertisement
Sign in to follow this  
Voxxius212

Adding a Font to Command Prompt throught the registry in C

This topic is 2890 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

My question is fairly simple, but requires a touch of backstory. I'm a member of a small team developing a game project for the command console using C, windows.h and the STL. The visuals are all ASCII, which means we are using the raster fonts that are available to the command window to draw our graphics with. The issue being that the fonts are 4 x 6, 6 x 8, 8 x 8 and so on. Leaving the smallest square dimensions to use for rendering to be 8 x 8. While this isn't the worst looking size in the world, the animations and sprites could be much more appealing with a 4 x 4 font, for example. We could use the 4 x 6 font, but minor adjustments would have to be made for vertical vs. horizontal drawing, which wouldn't be a huge ordeal but a square font fould be ideal. This brings me to my question.

Is it possible to add a 4 x 4 Raster Font created by myself, or downloaded from the web to the registry key for the Console Font? I've been looking on MSDN at the Registry Functions and I also came across http://support.microsoft.com/default.aspx?scid=KB%3BEN-US%3BQ247815 . It seems as though I need to open a Handle to the Registry somehow and then I can simply add values using RegCreateKeyEx ? The idea is to put this into an Installer, but I need to make sure it is even possible before I start to plan all of my graphics around it.

Thank you for any ideas, advice, questions, etc...

Share this post


Link to post
Share on other sites
Advertisement

My question is fairly simple, but requires a touch of backstory. I'm a member of a small team developing a game project for the command console using C, windows.h and the STL. The visuals are all ASCII, which means we are using the raster fonts that are available to the command window to draw our graphics with. The issue being that the fonts are 4 x 6, 6 x 8, 8 x 8 and so on. Leaving the smallest square dimensions to use for rendering to be 8 x 8. While this isn't the worst looking size in the world, the animations and sprites could be much more appealing with a 4 x 4 font, for example. We could use the 4 x 6 font, but minor adjustments would have to be made for vertical vs. horizontal drawing, which wouldn't be a huge ordeal but a square font fould be ideal. This brings me to my question.

Is it possible to add a 4 x 4 Raster Font created by myself, or downloaded from the web to the registry key for the Console Font? I've been looking on MSDN at the Registry Functions and I also came across http://support.micro...EN-US%3BQ247815 . It seems as though I need to open a Handle to the Registry somehow and then I can simply add values using RegCreateKeyEx ? The idea is to put this into an Installer, but I need to make sure it is even possible before I start to plan all of my graphics around it.

Thank you for any ideas, advice, questions, etc...


Why don't you just write a very quick console emulator in a graphics library and use that instead? Than you can use whatever graphics / font you like than. You'd get better color support and smooth scrolling as well.

Share this post


Link to post
Share on other sites
I agree with Daaark; rolling your own console-render has a lot of benefits that the ol' win32 console can't provide. I've done it myself with SDL, and it's relatively painless. Using SDL, your project can be cross-platform, you won't be limited to the 16-color VGA palette (if you don't want to, that is), you'll be able to supply your own font, and you can even do it fullscreen. :)

Share this post


Link to post
Share on other sites
I'm relatively new to C, so I'm not sure what writing your own game in SDL entails. This is a one semester school project that must be completed with pretty specific deadlines and specifications. We can only code in C, although tools used can be 3rd party. Windows.h can be included but we can't use Network or GDI. The graphics must be in ASCII or Raster Art. If it involves going against any of those rules then I can't do it. The limited resources are part of the challenge.

Share this post


Link to post
Share on other sites

I'm relatively new to C, so I'm not sure what writing your own game in SDL entails. This is a one semester school project that must be completed with pretty specific deadlines and specifications. We can only code in C, although tools used can be 3rd party. Windows.h can be included but we can't use Network or GDI. The graphics must be in ASCII or Raster Art. If it involves going against any of those rules then I can't do it. The limited resources are part of the challenge.
The windows console isn't the same as it used to be in DOS. In DOS it was very quick and you could go into different video modes to get more color support among other things. In Windows, the console is slower and less versatile.

Using a graphics you could just make a canvas to draw on, and make a few functions that would draw your own font onto it, emulating a console, but with better color support, and you could use any glyphs you wanted. If you can't use GDI, how are you supposed to use raster art?

Making changes to someone's registry, especially for something as trivial as a programming exercise, it not a good thing to do. You shouldn't ever be touching the registry unless you have good reason.

Share this post


Link to post
Share on other sites

[quote name='Voxx' timestamp='1295077784' post='4759198']
I'm relatively new to C, so I'm not sure what writing your own game in SDL entails. This is a one semester school project that must be completed with pretty specific deadlines and specifications. We can only code in C, although tools used can be 3rd party. Windows.h can be included but we can't use Network or GDI. The graphics must be in ASCII or Raster Art. If it involves going against any of those rules then I can't do it. The limited resources are part of the challenge.
The windows console isn't the same as it used to be in DOS. In DOS it was very quick and you could go into different video modes to get more color support among other things. In Windows, the console is slower and less versatile.

Using a graphics you could just make a canvas to draw on, and make a few functions that would draw your own font onto it, emulating a console, but with better color support, and you could use any glyphs you wanted. If you can't use GDI, how are you supposed to use raster art?

Making changes to someone's registry, especially for something as trivial as a programming exercise, it not a good thing to do. You shouldn't ever be touching the registry unless you have good reason.
[/quote]

I still think you're trying to lead me away from doing the program in the windows console, which is the criteria of the assignment. We draw with raster art by setting the console window to draw in a specific dimension raster font, and resize the window. Essentially the drawing is done with CHAR_INFOs, so a buffer filled with colors for each pixel and the ascii value to represent there and then drawn to console buffers and made active blah blah.. Most times the ascii is a ' ' so the background color shows 100%, but with stippled ascii characters and different foreground/background colors you can get a pretty wide range of shades. In reality we are piecing together bitmaps sprites into our own animation files and drawing those to the screen, but the actual rendering is done the same. The desire to display the font smaller is simply for more screen real-estate and better detail/resolution.

I can post some code describing how the rendering is done, but that isn't really the point of this thread.

Share this post


Link to post
Share on other sites
That's a creative way to hack your way around the given restrictions, but I wonder if it's worth the effort. Technically, you're still using the console, but likely not in the way your teacher intended, so this sounds rather risky to me. Are you sure this is ok? Perhaps you're forced to use the console because you have to focus on the program itself instead of it's representation...

We were once tasked to design a program without starting to implement it. Impatient as we were, we started implementing immediately after we came up with a design... but half-way down the road we were told to implement another groups design. We could've saved ourselves some work if we had just listened (on the other hand, it was fun to build two different programs, heh).

So yeah, I'll have to agree with the rest: don't use the console for something like this. But if you do have to use it, then accept that this is not what it's designed for. Having that said, there are many roguelikes that do make good use of console 'graphics'. It's crude, but the emphasis in these games clearly lies on the gameplay, not the visuals. Well, sorry I can't help with the font issue, but I hope my post was still helpful somehow. Good luck with your project. :)

Share this post


Link to post
Share on other sites
I can post some code describing how the rendering is done, but that isn't really the point of this thread.
I do understand all that. I have made similar games, using similar techniques. But this is still text mode graphics, and not raster graphics as you said.

I mentioned faking a console because it's a more common scenario these days. You are basically trying to squeeze blood from a stone with your font hack method. You can change the resolution and font size of the console both in your program, and in the console window context menu. You might try that to get more effective resolution. An 80x25 console only takes a small corner of my screen. I could easily set it to 160x50, or more.



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!