note 75718 deleted from function.imagettftext by cmb

From: Date: Tue, 13 Sep 2016 17:40:36 +0000
Subject: note 75718 deleted from function.imagettftext by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206578@lists.php.net to get a copy of this message
Note Submitter: Lassial at the google mail dot com ---- Creating multiline text with GD is bit complicated, one of the issues I've ran to is how to set line spacing, a normal feature in all type setting (even type writers). By default, line spacing with imagettftext seems to be 150 % or more, too much for me anyhow. Thus I've used the function below to get the lines closer to each other. By default, it appears to create 100 % linespacing, but it has not been tested thoroughly. null imagettfmultilinetext (resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text , $spacing) spacing is a coefficient, comparable to Line spacing in a word processors or graphics software, causing a shift relative to font size in the line spacing <?php function imagettfmultilinetext($image, $size, $angle, $x, $y, $color, $fontfile, $text, $spacing=1) { $lines=explode("\n",$text); for($i=0; $i< count($lines); $i++) { $newY=$y+($i * $size * $spacing); imagettftext($image, $size, $angle, $x, $newY, $color, $fontfile, $lines[$i], $spacing); } return null; } ?>

« previous php.notes (#206578) next »