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.
This commit is contained in:
parent
760b3d0667
commit
2c0490a26e
3 changed files with 14 additions and 12 deletions
|
@ -39,7 +39,7 @@ _stringnwidth(Font *f, char *s, Rune *r, int len)
|
|||
}
|
||||
}
|
||||
if((n = cachechars(f, sptr, rptr, cbuf, max, &wid, &subfontname)) <= 0){
|
||||
if(subfontname){
|
||||
if(n == 0){
|
||||
if(++try > 10)
|
||||
break;
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue