note 60992 deleted from function.imagettftext by cmb

From: Date: Sun, 13 Jan 2019 10:40:18 +0000
Subject: note 60992 deleted from function.imagettftext by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210047@lists.php.net to get a copy of this message
Note Submitter: nospam at nospam dot nospam ---- I've found that upsampling your text by a factor of 8 or more can really improve the readability of generated text, especially in smaller font sizes (9 or less). I find it also helps with fonts that have kerning to reduce space between letters such as capital T and capital A (TA) where the top-right of the T will be cut off due to GD "features". I can't tell you, the reader, exactly how to do this, as it will depend on how you are currently generating your text, but essentially what you want to try doing is upsize your font by a factor of 8 and then scale down the resulting image by the same factor. So if you were using font size 10, use font size 80 and use imagecopyresampled() to divide the width/height down again by 8. The resulting image will be a few pixels different in width / height compared to direct text writing, so make sure to check your image sizes if you are using fixed dimensions. Play around with other factors, 16 is a bit nicer but results in a higher CPU/RAM load when processing. Any higher is unnecessary I think. If possible you should also cache the image to a file instead of reprocessing it each request.

« previous php.notes (#210047) next »