commit 7f4daaa566a5aca486f081eaed7e706657347fca
parent 5f469ad212074b8940be46db4c93898e083c99ec
Author: glenda <glenda@9front.local>
Date: Wed, 21 Jul 2021 20:59:18 +0000
changing font via font file is now supported!
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/richterm.c b/richterm.c
@@ -238,7 +238,7 @@ generatepage(Rich *rich)
#define BSIZE 4096
Rectangle r;
- char *sp;
+ char *sp, buf[1024];
Object *obj;
int newline, tab, ymax;
Point pt;
@@ -270,8 +270,10 @@ generatepage(Rich *rich)
v->obj = obj;
v->page = &rich->page;
- v->font = font;
- // v->font = getfont(&fonts, ((Faux *)obj->ffont->aux)->data->p);
+ /* TODO: check if font->data->n is too long */
+ memcpy(buf, ((Faux *)obj->ffont->aux)->data->p, ((Faux *)obj->ffont->aux)->data->n);
+ buf[((Faux *)obj->ffont->aux)->data->n] = '\0';
+ v->font = getfont(&fonts, buf);
v->dp = sp;
v->length = aux->data->n;
@@ -339,7 +341,7 @@ getfont(struct Fonts *fonts, char *name)
if (strcmp(fonts->data[i]->name, name) == 0) return fonts->data[i];
}
if ((newfont = openfont(display, name)) == nil) {
- fprint(2, "can't load font %s\n", name);
+ fprint(2, "%r\n");
newfont = font;
} else {
addfont(fonts, newfont);