<?php
imagettftext($im, 15, 0, 470, $m, $black, $font, "this is testing of all");
?>
When I run this function I get the image with uneven spaces.
like this:
this is testin g o fall
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a so-called kerning problem. TrueType fonts contain information about the spacing between certain pairs of characters to achieve a natural flow of letters.
From my experience, GD’s TrueType function
imagettftext()often doesn’t use the kerning information contained in TrueType fonts, or does not use them well enough.Try
imagefttext()first. (notice theftinstead of thettf) It makes use of the FreeType library.If that doesn’t improve the result, you may have to resort to ImageMagick if your server supports it. But try the Freetype functions first.