Page 2 of 2
[Fixed] Best way of drawing text in graphics mode
Posted: Fri Aug 19, 2016 5:42 am
by Octacone
Okay so after some coding I finally found how to do this.
Thank you all guys for helping me out. I decided to use an array of characters and pull my wanted character upon request. It works flawlessly. It supports all the features I wanted it to support. Now I just need to fill my master array with all those 100 characters.
Re: Best way of drawing text in graphics mode
Posted: Fri Aug 19, 2016 6:11 am
by Ch4ozz
You gonna rewrite everything anyways if you want to support TTF later.
Static bitmap fonts are useless because they cant be scaled (they can using hqx algorithm which doesnt look too bad but its still a waste of power and memory), so it wont work in the long run with only one sized font.
Re: Best way of drawing text in graphics mode
Posted: Fri Aug 19, 2016 6:48 am
by onlyonemac
octacone wrote:I only have 100 characters and I do not need more. So I just need to create 156 empty character with random names?

So I need to assign ASCII values to every each one of my 100 characters?
How are your characters currently identified? Because unless it's something that can easily be converted to ASCII by adding an offset to a numerical value, believe me you want to change that. Unless you can perform an array lookup to find the corresponding bitmap for each character, then you need to change the way your characters are identified otherwise your code is never going to be efficient. There's really no reason not to use ASCII.
octacone wrote:I can not do 8x8 or anything like that, my arrays are all different. I also need to pass Array size information and character width information to my internal method in order to draw a character.
Well however your bitmaps are represented, do:
Code: Select all
typedef struct
{
// stuff for your bitmap here (size, pixels, etc.)
} character_bitmap;
character_bitmap font[256];
draw_character(char character, int x, int y)
{
character_bitmap bitmap = font[character];
draw_bitmap(bitmap, x, y); // however you're plotting the bitmap
}
Nothing really changes except the implementation of "character_bitmap".
[Solved] Best way of drawing text in graphics mode
Posted: Fri Aug 19, 2016 6:54 am
by Octacone
Well this issues has already been solved. I can display colored string and set their locations like so.