summaryrefslogtreecommitdiff
path: root/sys/src/libdraw/string.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-03-10 06:41:45 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-03-10 06:41:45 +0100
commit2c0490a26ed0565d5e69c88e64c8b185ecab0947 (patch)
tree31255a83056af8b36712da1906df1d9c552ab561 /sys/src/libdraw/string.c
parent760b3d06679aa690a5c83d6c9aeed6003f93fdc1 (diff)
libdraw: fix zero stringwidth() bug
stringwidth() and string() sometimes failed spuriously due to the wrong assumption that cachechars() will only fail when a different subfont is needed. in fact, cachechars() can fail for other reasons like when it resizes the fontcache (or fails todo so). theres also the case when loadchar() is unable to translate a character and returns 0. this case needs to be differentiated from such temporary conditions like fontcache resize or subfont load to stop the retry loop in string() and stringwidth(). now cachechars() returns -1 to indicate that it cannot proceed and we test this in string() and stringwidth() to skip over untranslatable characters to make progress instead of retrying.
Diffstat (limited to 'sys/src/libdraw/string.c')
-rw-r--r--sys/src/libdraw/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/libdraw/string.c b/sys/src/libdraw/string.c
index 2dc2a63e7..c15bf2777 100644
--- a/sys/src/libdraw/string.c
+++ b/sys/src/libdraw/string.c
@@ -92,7 +92,7 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i
}
}
if((n = cachechars(f, sptr, rptr, cbuf, max, &wid, &subfontname)) <= 0){
- if(subfontname){
+ if(n == 0){
if(++try > 10)
break;
continue;