diff options
author | Marvin Borner | 2020-08-16 00:44:53 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-16 00:44:53 +0200 |
commit | c4a0bc2571162ad83fc51eb823f1c535336041bf (patch) | |
tree | cba1169a027fea8884e882be601bf3cbaeaab654 /kernel/features/psf.c | |
parent | 9a827eb5f6ff58bf801bc98bcb653876428ebe69 (diff) |
Added psf/gui to libgui
...and some other things
Diffstat (limited to 'kernel/features/psf.c')
-rw-r--r-- | kernel/features/psf.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/kernel/features/psf.c b/kernel/features/psf.c deleted file mode 100644 index 004ed8f..0000000 --- a/kernel/features/psf.c +++ /dev/null @@ -1,57 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// PSF parser - -#include <def.h> -#include <gui.h> -#include <mem.h> -#include <print.h> -#include <psf.h> - -// Verifies the PSF magics -// Returns the PSF version or 0 -int psf_verify(char *data) -{ - struct psf1_header *header1 = (struct psf1_header *)data; - struct psf2_header *header2 = (struct psf2_header *)data; - - if (header1->magic[0] == PSF1_MAGIC_0 && header1->magic[1] == PSF1_MAGIC_1) - return 1; - else if (header2->magic[0] == PSF2_MAGIC_0 && header2->magic[1] == PSF2_MAGIC_1 && - header2->magic[2] == PSF2_MAGIC_2 && header2->magic[3] == PSF2_MAGIC_3) - return 2; - else - return 0; -} - -struct font *psf_parse(char *data) -{ - int version = psf_verify(data); - - char *chars; - int height; - int width; - int char_size; - - if (version == 1) { - chars = data + sizeof(struct psf1_header); - height = ((struct psf1_header *)data)->char_size; - width = 8; - char_size = ((struct psf1_header *)data)->char_size; - } else if (version == 2) { - chars = data + ((struct psf2_header *)data)->size; - height = ((struct psf2_header *)data)->height; - width = ((struct psf2_header *)data)->width; - char_size = ((struct psf2_header *)data)->char_size; - } else { - printf("Unknown font!\n"); - return 0; - } - - struct font *font = malloc(sizeof(*font)); - font->chars = chars; - font->height = height; - font->width = width; - font->char_size = char_size; - - return font; -} |