summaryrefslogtreecommitdiff
path: root/sys/src/libdraw/font.c
AgeCommit message (Collapse)Author
2014-03-10libdraw: fix zero stringwidth() bugcinap_lenrek
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.
2014-01-06libdraw: fix stringwidth problemscinap_lenrek
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()
2013-05-25libdraw: fix agefont crash when display == nil (from sources / ↵cinap_lenrek
agefont-nodisplay patch) If you run this: {for (i in `{seq 1 70000}) echo '½•α·'} | mc | wc mc will eventually suicide. The error comes from /sys/src/libdraw/font.c:/^agefont which assumes it has a display. Normally, this is set up by geninitdraw (usually via initdraw), but mc.c avoids that to avoid the screen redraws (flicker, at a minimum, but worse in long-running cases). graphics(2) does not prohibit this use, so I made the least intrusive change to make it work.
2013-05-04libdraw: fix font f->cacheimage nil dereferencecinap_lenrek
the initial fontresize() might fail but its error code is ignored potentially leaving f->cacheimage == nil. make sure we call fontresize() in loadchar() when theres no cacheimage and check the return value to avoid nil pointer dereference.
2011-11-10libdraw: dont abort() on failed allocimage in fontresize()cinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen