I was just wondering what's the best way to display text in 13h mode (320x200x256). Some people suggest creating bitmap images of characters and just outputting them to the screen. Any other ways? Thanks.
Printable View
I was just wondering what's the best way to display text in 13h mode (320x200x256). Some people suggest creating bitmap images of characters and just outputting them to the screen. Any other ways? Thanks.
Thats the way to go. Its fast, and easy (about as fast and easy as you can get, in fact). Even in games created today, that is the general method to display text.
Z.
All right, do you happen to know of an example of this (a source code of some program)? I understand the general idea, but there some little things that I would rather take a look at in action. What would you recommend for the text size (dimensions)?
I use 12x9 pixels, at the moment, and it works well (though it might be large at 320x200...
The actual code is really easy. Here is the general algorithm:
Basically, you are copying the pixels over to the screen, except for the pixels that are the transparent color that you choose.Code:for each letter:
find the upper left corner of letter in bitmap
loop through all pixels in letter, using dimensions you pick
if the current color is the transparent color, move to the next pixel
Z.
I just tried making a bitmap like that (using the whole ASCII chart) and it didn't really work for me. First of all, what program do you use? I tried doing this with MS Paint, but it doesn't seem to like very small fonts. Also, what font do you use, most fonts seem to have different letter width based on the character (like '!' would have less width then a 'W'), and how would you know what size to use for different dimensions?
I wrote a console app to print out all of the characters after the space character, then print-screened, the stuck it into paint. Its a fixed width font, so I know how big each char is.
Z.
I wrote this code couple of years ago.... I did not test this code for compilers other than Turbo C/C++ 3.0
In the attached zip are 2 font files a vga.h file, font.h, and a loadfont.cpp
Look in the vga.h file... you'll find functions you will really love :) and I spend a realllllyyyyy long time to code them. A lot of nights with little sleep :)
Anyways....
I lost the code with witch I created the font files, if you want to create other fonts, just try to figure out how the LoadFont works....
That is awesome! Even more that I needed. Thanks.
I found the code to create the font files....
So...
In this zip.... a cpp to create the font file and a mouse.h that the cpp uses....
This cpp uses a different type of graphics, I hope it works in your compiler... if it does not, tell me, and i'll make an EXE of the makefont.cpp, then it will work for sure....
When the app starts, put with & height then you have to press + until you get to the character you want to edit.... and - (minus key) to go back.... I just noticed that I did not make the program check when it goes over 255 (or less than 0) ... don't try it.... i did, and it crashed.. :)
Also... I did not make it ask in what file name to save everything, instead it will save it in "font3.fnt", you have to change the line "fl = fopen("Font3.fnt", "wb");"
Again... this code I originally made it for Turbo C/C++ 3.0, not sure if it works on other compiles....
And.... another thing..... if you use lot's of functions from my code.... and you plan to publish your code or program..... can you add my name to your about.... or wherever you mention your programming people list stuff..... :)
It feels like all the nights spent to make this code are for nothing, when I give my code like this.... I hope you understand...
Cool, I just tested it out and everything works great. Going to try and make a few fonts myself right now. I'll be sure to include your name in my programs that use this code. Thanks again.