richterm

"terminal emulator" with support for text fonts and images for plan9
git clone git://nsmpr.xyz/richterm.git
Log | Files | Refs | README

commit 40b18ba4cb4e1dcc72bb62474b498b4cef9cd20c
parent 0edd75f5c35b5ebc24818e5558ee67c0c6058586
Author: glenda <glenda@9front.local>
Date:   Fri, 23 Apr 2021 07:39:46 +0000

start implementing font support

Diffstat:
Mrichterm.c | 11+++++++++--
Mui.h | 2++
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/richterm.c b/richterm.c @@ -49,7 +49,8 @@ threadmain(int argc, char **argv) rich.obj = malloc(sizeof(Object) * 4); rich.count = 4; rich.obj[0] = (Object){"text", nil, "hello ", strlen("hello ")}; - rich.obj[1] = (Object){"text", nil, "world", strlen("world")}; + rich.obj[1] = (Object){"text", + "font=/lib/font/bit/terminusunicode.18.font", "world", strlen("world")}; rich.obj[2] = (Object){"text", nil, "!", strlen("!")}; rich.obj[3] = (Object){"text", nil, "\n", strlen("\n")}; @@ -125,7 +126,13 @@ generatepage(Rectangle r, Rich *rich) view.obj = obj; view.page = &page; view.dp = obj->data; - view.r = Rpt(pt, addpt(pt, Pt(100,20))); + view.length = strlen(view.dp); + view.font = font; + view.r = (Rectangle){ + pt, + addpt(pt, Pt(stringnwidth(view.font, view.dp, view.length), + view.font->height)) + }; page.view[page.count -1] = view; pt.y = view.r.max.y; } diff --git a/ui.h b/ui.h @@ -18,6 +18,8 @@ typedef struct Page Page; struct View { Object *obj; char *dp; + long length; + Font *font; Rectangle r; Page *page; };