aboutsummaryrefslogtreecommitdiff
path: root/src/features/psf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/psf.c')
-rw-r--r--src/features/psf.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/features/psf.c b/src/features/psf.c
deleted file mode 100644
index adf2aa2..0000000
--- a/src/features/psf.c
+++ /dev/null
@@ -1,58 +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>
-#include <vesa.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;
-}