note 60992 added to function.imagettftext
| From: | nospam at nospam dot nospam | Date: | Sun, 22 Jan 2006 23:51:46 +0000 |
| Subject: | note 60992 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102252@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 203.16.234.91
Probable Submitter: 203.91.232.122
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60992
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60992&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60992&report=yes
Search -- http://master.php.net/manage/user-notes.php