From 93f12c7673469a316a94834776a106e38e4c7c4c Mon Sep 17 00:00:00 2001 From: leency Date: Thu, 13 Mar 2025 01:26:04 +0200 Subject: [PATCH] allow applications to work nicely without .kf files --- programs/cmm/lib/kfont.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/programs/cmm/lib/kfont.h b/programs/cmm/lib/kfont.h index 8a45d91c4..2028d185f 100644 --- a/programs/cmm/lib/kfont.h +++ b/programs/cmm/lib/kfont.h @@ -66,10 +66,11 @@ int kfont_char_width[255]; :bool KFONT::init(dword font_path) { dword fsize_notused; - if(font)free(font); + if(font) font = free(font); read_file(font_path, #font_begin, #fsize_notused); if(!EAX) { - RunProgram("/sys/@notify", "'Error: KFONT is not loaded.' -E"); + RunProgram("/sys/@notify", "'Error: KFONT is not loaded' -E"); + kfont.height = 14; return false; } changeSIZE(); @@ -99,6 +100,10 @@ int kfont_char_width[255]; :dword KFONT::getsize(byte font_size, dword text1) { + if (!font) { + size.width = strlen(text1) * 8; + return size.width; + } size.height = size.width = 0; size.offset_x = size.offset_y = -1; if (size.pt != font_size) { @@ -275,6 +280,11 @@ inline fastcall dword b32(EAX) { return DSDWORD[EAX]; } { if(!text1)return 0; getsize(font_size, text1); + if (!font) { + EDI = _background; + WriteText(x, y, 0xD0, _color, text1); + return size.width; + } raw_size = NULL; WriteIntoBuffer(0, -size.offset_y, size.width-size.offset_x, size.height-size.offset_y, _background, _color, font_size, text1);