Actually I have an .efi application (intended to be a very early kernel) that set-up graphics along with other things, I use this graphics to make a "set_pixel" function, and a few days ago I had the need of printing text.
After a few days of research I found that my only solution is to write all of the characters that I need to use with this "set_pixel" function and some other derivations that I made ("draw_line", etc.)
As you can imagine, this is a very tedious and slow task, there is another solution than writing all the characters "by hand"? A method to import a font and use it? Thanks in advance!
Asked
Active
Viewed 356 times
0

Rottenheimer2
- 425
- 1
- 5
- 13
1 Answers
0
Here's my own solution.
I have created a simple font (incomplete for now ...) in the form of an header file. Then I use this function in order to draw a character into the GOP buffer:
void drawChar(uint32_t *buffer, uint32_t x, uint32_t y, uint32_t color, wchar_t charcode) {
extern wchar_t font_system_8x16[KAOS_FONTS_SIZE];
wchar_t p = charcode * 128 - 128; // Size of a font's character
for (int l = 0; l < 16; l++) {
for (int c = 0; c < 8; c++) {
if (font_system_8x16[p] == 1) {
drawPoint(buffer, x + c, y + l, color);
}
p++;
}
}
}
Feel free to get inspired.
EDIT: For a faster way to generate header file, look at this C header file with bitmapped fonts

Guy Avraham
- 3,482
- 3
- 38
- 50

RTDaemons
- 16
-
Looks like a nice approach, I will try it – Rottenheimer2 Dec 21 '17 at 15:37