I'm currently developing a really simple GUI for my operating system. And I've just found this 1-year-ago topic of SSFN from this post: https://wiki.osdev.org/Scalable_Screen_Font
Recently I want to add the ability of rendering text (more precisely, Unicode) on VRam, I've tried to use PSFs format & plain data written in array, but these method are too... clumsy and difficult to maintain, so I changed my plan and started to use SSFN library to render text.
Unfortunately, my OS is still in early-stage. I cannot use any file function such as
Code: Select all
fread()
I found that there are a few fonts attached to the SSFN directory, I moved one of them, FreeSans.sfn, into my project directory. I simply created fonts.c and packaged an API:
Code: Select all
#define SSFN_CONSOLEBITMAP_HICOLOR
#include "font.h"
#include "ssfn.h"
extern char _binary_drivers_FreeSans_sfn_start;
/*
* @brief Plot a character on the VRam.
*
* @param vram Video RAM,
* @param bpr Bytes per row.
* @param x X axis of the char.
* @param y Y axis of the char.
* @param w Width of the screen.
* @param h Height of the screen.
* @param fg Foreground color.
* @param bg Background color.
* @param unicode Unicode of the char.
*/
void plot_font(uint8_t *vram, uint16_t bpr, int x, int y, int w, int h,
uint32_t fg, uint32_t bg, uint32_t unicode) {
ssfn_src = &_binary_drivers_FreeSans_sfn_start;
ssfn_dst.ptr = vram;
ssfn_dst.p = bpr;
ssfn_dst.fg = fg;
ssfn_dst.bg = bg;
ssfn_dst.x = x;
ssfn_dst.y = y;
ssfn_dst.w = w;
ssfn_dst.h = h;
ssfn_putc(unicode);
}
Code: Select all
C_SOURCES = ......
HEADERS = ......
OBJ = ${C_SOURCES:.c=.o ...... drivers/FreeSans.o}
CC = /path/to/cc
GDB = /usr/local/bin/gdb
CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions -m32
.............(omitted)
%.o: %.sfn
i386-elf-objcopy -O elf32-i386 -B i386 -I binary $< $@
Code: Select all
if(!ssfn_src || ssfn_src->magic[0] != 'S' || ssfn_src->magic[1] != 'F' || ssfn_src->magic[2] != 'N' ||
ssfn_src->magic[3] != '2' || !ssfn_dst.ptr || !ssfn_dst.p) return SSFN_ERR_INVINP;
So, my question is, how do I transform .sfn to .o correctly? If there is no such method, are there any alternatives