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.
[Solved] Best way of drawing text in graphics mode
[Fixed] Best way of drawing text in graphics mode
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: Best way of drawing text in graphics mode
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.
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.
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Best way of drawing text in graphics mode
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 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?
Well however your bitmaps are represented, do: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.
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
}
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
[Solved] Best way of drawing text in graphics mode
Well this issues has already been solved. I can display colored string and set their locations like so.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader