Change: font
This commit is contained in:
Binary file not shown.
BIN
include/fonts/viscii10-8x16.psfu
Normal file
BIN
include/fonts/viscii10-8x16.psfu
Normal file
Binary file not shown.
4
makefile
4
makefile
@@ -26,8 +26,8 @@ PROGRAM_OBJECTS = $(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%, $(PROGRAM_SOURCES:.c=.o
|
|||||||
TOOLCHAIN_SRC = https://newos.org/toolchains/i386-elf-7.5.0-Linux-x86_64.tar.xz
|
TOOLCHAIN_SRC = https://newos.org/toolchains/i386-elf-7.5.0-Linux-x86_64.tar.xz
|
||||||
TOOLCHAIN_FILE = i386-elf-7.5.0-Linux-x86_64.tar.xz
|
TOOLCHAIN_FILE = i386-elf-7.5.0-Linux-x86_64.tar.xz
|
||||||
|
|
||||||
FONT_OBJ = $(OBJ_DIR)/fonts/UniCyrExt_8x16.o
|
FONT_OBJ = $(OBJ_DIR)/fonts/viscii10-8x16.o
|
||||||
FONT_SRC = $(FONTS_DIR)/UniCyrExt_8x16.psf
|
FONT_SRC = $(FONTS_DIR)/viscii10-8x16.psfu
|
||||||
|
|
||||||
all: $(OBJ_DIR) kernel.elf programs
|
all: $(OBJ_DIR) kernel.elf programs
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,51 @@
|
|||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "../kernel/system.h"
|
#include "../kernel/system.h"
|
||||||
|
#include "../kernel/kheap.h"
|
||||||
|
|
||||||
extern char* framebuffer;
|
extern char* framebuffer;
|
||||||
|
|
||||||
|
void psf_init()
|
||||||
|
{
|
||||||
|
uint16_t glyph = 0;
|
||||||
|
PSF_font *font = (PSF_font*)&_binary_include_fonts_viscii10_8x16_psfu_start;
|
||||||
|
if (font->flags)
|
||||||
|
{
|
||||||
|
unicode = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* s = (char*)((unsigned char*)&_binary_include_fonts_viscii10_8x16_psfu_start + font->headersize + font->numglyph * font->bytesperglyph);
|
||||||
|
unicode = calloc(USHRT_MAX, 2);
|
||||||
|
|
||||||
|
while(s>_binary_include_fonts_viscii10_8x16_psfu_end){
|
||||||
|
uint16_t uc = (uint16_t)((unsigned char *)s[0]);
|
||||||
|
if(uc == 0xFF) {
|
||||||
|
glyph++;
|
||||||
|
s++;
|
||||||
|
continue;
|
||||||
|
} else if(uc & 128) {
|
||||||
|
/* UTF-8 to unicode */
|
||||||
|
if((uc & 32) == 0 ) {
|
||||||
|
uc = ((s[0] & 0x1F)<<6)+(s[1] & 0x3F);
|
||||||
|
s++;
|
||||||
|
} else
|
||||||
|
if((uc & 16) == 0 ) {
|
||||||
|
uc = ((((s[0] & 0xF)<<6)+(s[1] & 0x3F))<<6)+(s[2] & 0x3F);
|
||||||
|
s+=2;
|
||||||
|
} else
|
||||||
|
if((uc & 8) == 0 ) {
|
||||||
|
uc = ((((((s[0] & 0x7)<<6)+(s[1] & 0x3F))<<6)+(s[2] & 0x3F))<<6)+(s[3] & 0x3F);
|
||||||
|
s+=3;
|
||||||
|
} else
|
||||||
|
uc = 0;
|
||||||
|
}
|
||||||
|
/* save translation */
|
||||||
|
unicode[uc] = glyph;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color)
|
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color)
|
||||||
{
|
{
|
||||||
uint32_t* pixel_addr = (uint32_t*)((uint8_t*)fb + y * pitch + x *(bpp / 8));
|
uint32_t* pixel_addr = (uint32_t*)((uint8_t*)fb + y * pitch + x *(bpp / 8));
|
||||||
@@ -18,13 +60,13 @@ void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color)
|
|||||||
|
|
||||||
void draw_char(unsigned short int c, int cx, int cy, uint32_t fg, uint32_t bg)
|
void draw_char(unsigned short int c, int cx, int cy, uint32_t fg, uint32_t bg)
|
||||||
{
|
{
|
||||||
PSF_font *font = (PSF_font*)&_binary_include_fonts_UniCyrExt_8x16_psf_start;
|
PSF_font *font = (PSF_font*)&_binary_include_fonts_viscii10_8x16_psfu_start;
|
||||||
int bytesperline=(font->width+7)/8;
|
int bytesperline=(font->width+7)/8;
|
||||||
if (unicode != NULL) {
|
if (unicode != NULL) {
|
||||||
c = unicode[c];
|
c = unicode[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* glyph = (unsigned char*)&_binary_include_fonts_UniCyrExt_8x16_psf_start + font->headersize + (c>0&&c<font->numglyph?c:0)*font->bytesperglyph;
|
unsigned char* glyph = (unsigned char*)&_binary_include_fonts_viscii10_8x16_psfu_start + font->headersize + (c>0&&c<font->numglyph?c:0)*font->bytesperglyph;
|
||||||
|
|
||||||
int offs =
|
int offs =
|
||||||
(cy * font->height * scanline) +
|
(cy * font->height * scanline) +
|
||||||
@@ -54,7 +96,7 @@ void scroll()
|
|||||||
{
|
{
|
||||||
serial_printf(3, "Scrolling...\r");
|
serial_printf(3, "Scrolling...\r");
|
||||||
uint32_t bg_color = 0x00000000;
|
uint32_t bg_color = 0x00000000;
|
||||||
PSF_font *font = (PSF_font*)&_binary_include_fonts_UniCyrExt_8x16_psf_start;
|
PSF_font *font = (PSF_font*)&_binary_include_fonts_viscii10_8x16_psfu_start;
|
||||||
|
|
||||||
int line_size = font->height * scanline;
|
int line_size = font->height * scanline;
|
||||||
int framebuffer_size = scanline * font->height * (1080/font->height);
|
int framebuffer_size = scanline * font->height * (1080/font->height);
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern int scanline;
|
extern int scanline;
|
||||||
extern char _binary_include_fonts_UniCyrExt_8x16_psf_start;
|
|
||||||
uint16_t* unicode;
|
|
||||||
|
|
||||||
|
extern char _binary_include_fonts_viscii10_8x16_psfu_start;
|
||||||
|
extern char _binary_include_fonts_viscii10_8x16_psfu_end;
|
||||||
|
uint16_t* unicode;
|
||||||
#define PIXEL uint32_t
|
#define PIXEL uint32_t
|
||||||
|
|
||||||
|
#define USHRT_MAX 10000
|
||||||
#define PSF1_FONT_MAGIC 0x0436
|
#define PSF1_FONT_MAGIC 0x0436
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -38,5 +40,6 @@ typedef struct {
|
|||||||
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color);
|
void putpixel(uint32_t* fb, int pitch, int bpp, int x, int y, uint32_t color);
|
||||||
void draw_char(unsigned short int c, int cx, int cy, uint32_t fg, uint32_t bg);
|
void draw_char(unsigned short int c, int cx, int cy, uint32_t fg, uint32_t bg);
|
||||||
void scroll();
|
void scroll();
|
||||||
|
void psf_init();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void kmain(multiboot2_info *mb_info)
|
|||||||
serial_printf(3, "Framebuffer Pitch: %u", fb_info->framebuffer_pitch);
|
serial_printf(3, "Framebuffer Pitch: %u", fb_info->framebuffer_pitch);
|
||||||
serial_printf(3, "Framebuffer BPP: %u", fb_info->framebuffer_bpp);
|
serial_printf(3, "Framebuffer BPP: %u", fb_info->framebuffer_bpp);
|
||||||
}
|
}
|
||||||
|
psf_init();
|
||||||
printf("[kernel] multiboot2 info at 0x%x, size=%u\n", mb_info, mb_info->total_size);
|
printf("[kernel] multiboot2 info at 0x%x, size=%u\n", mb_info, mb_info->total_size);
|
||||||
printf("[kernel] framebuffer discovered at 0x%x\n", (unsigned int)fb_info->framebuffer_addr);
|
printf("[kernel] framebuffer discovered at 0x%x\n", (unsigned int)fb_info->framebuffer_addr);
|
||||||
printf("[kernel] fb0: width=%u, height=%u, pitch=%u, bpp=%u\n", fb_info->framebuffer_width, fb_info->framebuffer_height, fb_info->framebuffer_pitch, fb_info->framebuffer_bpp);
|
printf("[kernel] fb0: width=%u, height=%u, pitch=%u, bpp=%u\n", fb_info->framebuffer_width, fb_info->framebuffer_height, fb_info->framebuffer_pitch, fb_info->framebuffer_bpp);
|
||||||
|
|||||||
Reference in New Issue
Block a user