Drawing text working using Framebuffer.blit_alpha_bitmap()
This commit is contained in:
parent
7562be585f
commit
2d7bf5197f
@ -15,7 +15,7 @@ configure do
|
||||
end
|
||||
|
||||
# Kernel default font size.
|
||||
KFONT_SIZE = 15
|
||||
KFONT_SIZE = 18
|
||||
|
||||
class HulkBinObj < Builder
|
||||
def run(options)
|
||||
|
@ -93,28 +93,28 @@ static void generate(const char * d_file_name)
|
||||
fprintf(fh, "struct CharInfo {\n");
|
||||
fprintf(fh, " uint width;\n");
|
||||
fprintf(fh, " uint height;\n");
|
||||
fprintf(fh, " uint top;\n");
|
||||
fprintf(fh, " uint left;\n");
|
||||
fprintf(fh, " int top;\n");
|
||||
fprintf(fh, " int left;\n");
|
||||
fprintf(fh, " const ubyte[] bitmap;\n");
|
||||
fprintf(fh, "};\n");
|
||||
fprintf(fh, "struct FontInfo {\n");
|
||||
fprintf(fh, " uint line_height;\n");
|
||||
fprintf(fh, " uint advance;\n");
|
||||
fprintf(fh, " uint baseline_offset;\n");
|
||||
fprintf(fh, " int baseline_offset;\n");
|
||||
fprintf(fh, " const CharInfo[] chars;\n");
|
||||
fprintf(fh, "};\n");
|
||||
fprintf(fh, "__gshared const FontInfo kfont = {\n");
|
||||
fprintf(fh, " %du,\n", line_height);
|
||||
fprintf(fh, " %du,\n", max_advance);
|
||||
fprintf(fh, " %du,\n", baseline_offset);
|
||||
fprintf(fh, " %d,\n", baseline_offset);
|
||||
fprintf(fh, " [\n");
|
||||
for (int i = 0; i < N_CHARS; i++)
|
||||
{
|
||||
fprintf(fh, " CharInfo(\n");
|
||||
fprintf(fh, " %du,\n", char_infos[i].width);
|
||||
fprintf(fh, " %du,\n", char_infos[i].height);
|
||||
fprintf(fh, " %du,\n", char_infos[i].top);
|
||||
fprintf(fh, " %du,\n", char_infos[i].left);
|
||||
fprintf(fh, " %d,\n", char_infos[i].top);
|
||||
fprintf(fh, " %d,\n", char_infos[i].left);
|
||||
if (char_infos[i].width > 0)
|
||||
{
|
||||
fprintf(fh, " [\n");
|
||||
|
@ -8,6 +8,7 @@ import hulk.bootinfo;
|
||||
import hulk.framebuffer;
|
||||
import hos.memory;
|
||||
import ldc.attributes;
|
||||
import hulk.kfont;
|
||||
|
||||
private __gshared Framebuffer fb;
|
||||
|
||||
@ -34,6 +35,15 @@ extern(C) void hulk_start(ulong rdi, ulong rsi, ulong rdx, BootInfo * bootinfo)
|
||||
memset32(&bootinfo.fb.buffer[y * bootinfo.fb.stride + 20u], 0x001199u, 20u);
|
||||
}
|
||||
|
||||
string message = "Hello, world! 0123456789!@#$%^&*()_-=+[]{};:\"'<>,./";
|
||||
int x = 100u;
|
||||
foreach (ch; message)
|
||||
{
|
||||
const(CharInfo) * ci = &kfont.chars[ch];
|
||||
fb.blit_alpha_bitmap(x + ci.left, 100 + ci.top - ci.height, ci.bitmap, ci.width, ci.height, 0x0088CCu);
|
||||
x += kfont.advance;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user