aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/features/psf.c44
-rw-r--r--src/inc/psf.h6
-rw-r--r--src/main.c3
3 files changed, 32 insertions, 21 deletions
diff --git a/src/features/psf.c b/src/features/psf.c
index 7b6a90a..ef63161 100644
--- a/src/features/psf.c
+++ b/src/features/psf.c
@@ -23,34 +23,33 @@ int psf_verify(char *data)
}
// Will be removed in the future
-void psf_test(char *chars)
+void psf_test(char *chars, int height, int width, int char_size)
{
char ch = 'a';
int x = 50;
int y = 400;
const u32 c[3] = { 0xff, 0x00, 0x00 };
- int font_height = 16;
- int font_width = 8;
+ printf("%d %d %d\n", height, width, char_size);
int pos = x * vbe_bpl + y * vbe_pitch;
char *draw = (char *)&fb[pos];
u16 row = 0;
- for (int cy = 0; cy <= font_height; cy++) {
- row = chars[ch * font_height + cy];
+ for (int cy = 0; cy <= height; cy++) {
+ row = chars[ch * char_size + cy * ((width + 7) / 8)];
- for (int cx = 0; cx <= font_width + 1; cx++) {
- if (row & 0x80) {
+ for (int cx = 0; cx <= width + 1; cx++) {
+ if (row & (1 << (width - 1))) {
draw[vbe_bpl * cx] = (char)c[2];
draw[vbe_bpl * cx + 1] = (char)c[1];
draw[vbe_bpl * cx + 2] = (char)c[0];
- /* } else { */
- /* draw[vbe_bpl * cx] = (char)c[2]; */
- /* draw[vbe_bpl * cx + 1] = (char)terminal_background[1]; */
- /* draw[vbe_bpl * cx + 2] = (char)terminal_background[0]; */
- /* } */
}
+ /* } else { */
+ /* draw[vbe_bpl * cx] = (char)c[2]; */
+ /* draw[vbe_bpl * cx + 1] = (char)terminal_background[1]; */
+ /* draw[vbe_bpl * cx + 2] = (char)terminal_background[0]; */
+ /* } */
row <<= 1;
}
draw += vbe_pitch;
@@ -62,14 +61,25 @@ char *psf_parse(char *data)
int version = psf_verify(data);
char *chars;
- if (version == 1)
+ int height;
+ int width;
+ int char_size;
+
+ if (version == 1) {
chars = data + sizeof(struct psf1_header);
- else if (version == 2)
- chars = data + sizeof(struct psf2_header);
- else
+ 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 {
return 0;
+ }
- psf_test(chars);
+ psf_test(chars, height, width, char_size);
return chars;
}
diff --git a/src/inc/psf.h b/src/inc/psf.h
index 3394f9c..ced3025 100644
--- a/src/inc/psf.h
+++ b/src/inc/psf.h
@@ -19,8 +19,8 @@
struct psf1_header {
u8 magic[2];
- u8 file_mode;
- u8 font_height;
+ u8 mode;
+ u8 char_size;
};
/**
@@ -38,7 +38,7 @@ struct psf2_header {
u32 size;
u32 flags;
u32 glyph_count;
- u32 bytes_per_glyph;
+ u32 char_size;
u32 height;
u32 width;
};
diff --git a/src/main.c b/src/main.c
index f95680e..4dee1fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,7 +28,8 @@ void main(struct mem_info *mem_info, struct vid_info *vid_info)
serial_install();
ls_root();
- psf_parse(read_file("/font/spleen-8x16.psfu"));
+ /* psf_parse(read_file("/font/spleen-8x16.psfu")); */
+ psf_parse(read_file("/font/spleen-16x32.psfu"));
while (1) {
};