Change framebuffer terminal font

This commit is contained in:
Thomas Lovén 2022-01-14 00:39:41 +01:00
parent 8b7e9a454b
commit a1add78fa2
4 changed files with 50 additions and 4 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ external/
src/kernel/kernel src/kernel/kernel
src/libmittos/libmittos.a src/libmittos/libmittos.a
src/libmittos/graphics/u_vga16.termfont.inc

View File

@ -17,6 +17,9 @@ LDFLAGS := -nostdlib -r
libmittos.a: $(OBJ) libmittos.a: $(OBJ)
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
graphics/graphics.o: graphics/u_vga16.termfont.inc
graphics/u_vga16.termfont.inc:
${BUILDROOT}/toolchain/build-uni_vga.sh
# Automatic dependency tracking # Automatic dependency tracking
DEP := $(OBJ:.o=.d) DEP := $(OBJ:.o=.d)

View File

@ -5,7 +5,7 @@
#define incptr(p, n) ((void *)(((uintptr_t)(p)) + (n))) #define incptr(p, n) ((void *)(((uintptr_t)(p)) + (n)))
#include "termfont.inc" #include "u_vga16.termfont.inc"
void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr) void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr)
{ {
@ -52,12 +52,12 @@ void draw_rect(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_
putpixel(ctx, x, _y, clr); putpixel(ctx, x, _y, clr);
putpixel(ctx, x+width, _y, clr); putpixel(ctx, x+width, _y, clr);
} }
} }
void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c) void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c)
{ {
unsigned char *chr = c ? font[(int)c-0x20]: font[0];
char *chr = c ? font[(int)c-0x20]: font[0];
if(x >= ctx->width || y >= ctx->height) return; if(x >= ctx->width || y >= ctx->height) return;
uint64_t loc = \ uint64_t loc = \
y * ctx->pitch + \ y * ctx->pitch + \

42
toolchain/build-uni_vga.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh -e
mkdir -p /opt/external && cd /opt/external
[ -f "uni-vga.tgz" ] || wget "https://www.inp.nsk.su/~bolkhov/files/fonts/univga/uni-vga.tgz"
[ -d "uni_vga" ] || tar -xf uni-vga.tgz
cd uni_vga
python3 - << EOF
codepoint = 0
reading = False
chars = {}
with open("u_vga16.bdf") as fp:
while line := fp.readline():
if line.startswith("ENCODING"):
codepoint = int(line.split()[1])
continue
if line.startswith("BITMAP"):
values = []
while True:
line = fp.readline()
if line.startswith("ENDCHAR"):
break
values.append(int(line, 16))
chars[codepoint] = values
with open("u_vga16.termfont.inc", "w") as fp:
fp.write("// THIS FILE IS GENERATED BY toolchain/build-univga-font.sh\n")
fp.write(f"unsigned char font[{127-32}][16] =")
fp.write("{\n")
for codepoint in range(32, 127):
fp.write("\t{" + ", ".join([f"0x{v:02X}" for v in chars.get(codepoint, [])]) + "},\n")
fp.write("};")
EOF
cp u_vga16.termfont.inc ${BUILDROOT}/src/libmittos/graphics/.