ref: 2b6fb27de2a0232a38bfc4729f101c18db3ff4ed
parent: 0bb5ea6bf8c90ee7527637efe5ccf545e7149043
author: phil9 <telephil9@gmail.com>
date: Thu Mar 24 01:41:41 EDT 2022
fix unicode rendering
--- a/dview.c
+++ b/dview.c
@@ -53,6 +53,7 @@
Point p, lp;
Image *c;
char buf[1024] = {0};
+ Rune r;
n = 0;
w = 0;
@@ -79,16 +80,18 @@
p = Pt(Padding, Padding);
inlink = 0;
cl = 0;
- for(i = 0; i < l; i++){
+ for(i = 0; i < l; ){
switch(d->text[i]){
case '\n':
p.x = Padding;
p.y += font->height;
+ ++i;
break;
case '{':
cl = 0;
lp = p;
inlink = 1;
+ ++i;
break;
case '}':
links[nlinks].b = b;
@@ -97,6 +100,7 @@
nlinks += 1;
cl = 0;
inlink = 0;
+ ++i;
break;
default:
c = cols->text;
@@ -104,7 +108,8 @@
c = cols->focus;
links[nlinks].text[cl++] = d->text[i];
}
- p = stringn(b->b, p, c, ZP, font, d->text + i, 1);
+ i += chartorune(&r, d->text + i);
+ p = runestringn(b->b, p, c, ZP, font, &r, 1);
break;
}
}