summaryrefslogtreecommitdiff
path: root/sys/src/libdraw/font.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-01-06 03:49:14 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-01-06 03:49:14 +0100
commite3b49509662cc1da997db4113b743d477a9e1ac0 (patch)
tree15099663e1d54217eb5d1558e780423b776a20b4 /sys/src/libdraw/font.c
parentb7ab1354e3fdf32d2a587de00b4b324779b34b20 (diff)
libdraw: fix stringwidth problems
cachechars() used to skip over characters on its own when loadchar() could not find the character or a PJW replacement. this resulted in wrong width calculation. now we just return and handle the case inside _string and _stringwidth. fix subfont leak in stringwidth() remove annoying prints in stringwidth()
Diffstat (limited to 'sys/src/libdraw/font.c')
-rw-r--r--sys/src/libdraw/font.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/src/libdraw/font.c b/sys/src/libdraw/font.c
index 5cda3f25d..4eaeb9e8d 100644
--- a/sys/src/libdraw/font.c
+++ b/sys/src/libdraw/font.c
@@ -10,7 +10,7 @@ static int freeup(Font*);
int
cachechars(Font *f, char **ss, Rune **rr, ushort *cp, int max, int *wp, char **subfontname)
{
- int i, th, sh, h, ld, w, rw, wid, nc;
+ int i, th, sh, h, w, rw, wid, nc;
char *sp;
Rune r, *rp, vr;
ulong a;
@@ -81,12 +81,9 @@ cachechars(Font *f, char **ss, Rune **rr, ushort *cp, int max, int *wp, char **s
if(c->age == f->age) /* flush pending string output */
break;
- ld = loadchar(f, r, c, h, i, subfontname);
- if(ld <= 0){
- if(ld == 0)
- continue;
+ if(loadchar(f, r, c, h, i, subfontname) <= 0)
break;
- }
+
c = &f->cache[h]; /* may have reallocated f->cache */
Found: