Page 1 of 1
Urgent - Problem update
Posted: 2016-09-22T02:03:14-07:00
by figou92
Hello,
We were working with ImageMagick 6.6.0-4 and every thing was great.
We have updated to 6.9 and now arc text is doing bad stuffs.... look at the picture. Anyone could help wuth this issue ?
Re: Urgent - Problem update
Posted: 2016-09-22T07:03:03-07:00
by snibgo
This is the IMagick forum? Are you using IMagick?
It may help if you show the code you use to create that image.
Re: Urgent - Problem update
Posted: 2016-09-23T00:54:49-07:00
by figou92
function imagettftextarc2($image, $size, $angle, $x, $y, $r, $color, $fontfile, $text, $dir=false, $float_indice = 0.5, $xDebutContainer = 8, $txtMaxWidth = 240){
$tabAfterResize = resizeFont($text, $size, $txtMaxWidth, $fontfile );
$size = $tabAfterResize['font_size'];
//Centrer le texte dans l'arc
// $xDebutContainer = 0;
// echo $tabAfterResize['str_size'].'pi';
if($dir == false){
$zoneX = ceil($xDebutContainer + (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI));
}else
{
$zoneX = ceil($xDebutContainer - (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI) );
}
$sbox = imagettfbbox($size, 0, $fontfile, ' ');
$sbox = ($sbox[2]-$sbox[0])* $float_indice;
$angle = $angle + ($zoneX ) ;
//$angle en radian
// $angle = $angle * M_PI / 180;
$angle = deg2rad($angle);
foreach(preg_split('//u', $text) AS $t){
$px = $x+$r*cos($angle);
$py = $y+$r*sin($angle);
/*
$px = round($x+$r*cos($angle));
$py = round($y+$r*sin($angle));
*/
//Retransformation en degres pour l'affichage
$dirangle = (360-(M_PI/2+$angle)*180/M_PI+($dir?180:0))%360;
$box = imagettfbbox($size, 0, $fontfile, $t);
$dx = ($box[2]-$box[0]);
// echo "angle : ".$dirangle."<br/>";
if($angle < 2.85 && $angle > 1.80 && ($dx >= ($size -5)))
{
$dirangle = $dirangle + 7;
$dx = $dx - 3;
}elseif($angle < 1.45 && $angle > 0.80 && ($dx >= ($size -3))){
$dirangle = $dirangle + 5;
}elseif($angle < 1.77 && $angle > 1.49)
{
$dirangle = $dirangle + 5;
}
//$dirangle = $dirangle + 7;
if($dx >= ($size -1))
{
$dx = $dx -5;
}
$da = abs(asin(($dx+$sbox)/$r));
imagettftext($image, $size, $dirangle, $px , $py, $color, $fontfile, $t);
if($dir){
$angle-=$da;
}else{
$angle+=$da;
}
}
}
Re: Urgent - Problem update
Posted: 2016-09-23T00:55:06-07:00
by figou92
Code: Select all
function imagettftextarc2($image, $size, $angle, $x, $y, $r, $color, $fontfile, $text, $dir=false, $float_indice = 0.5, $xDebutContainer = 8, $txtMaxWidth = 240){
$tabAfterResize = resizeFont($text, $size, $txtMaxWidth, $fontfile );
$size = $tabAfterResize['font_size'];
//Centrer le texte dans l'arc
// $xDebutContainer = 0;
// echo $tabAfterResize['str_size'].'pi';
if($dir == false){
$zoneX = ceil($xDebutContainer + (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI));
}else
{
$zoneX = ceil($xDebutContainer - (($txtMaxWidth - $tabAfterResize['str_size']) / M_PI) );
}
$sbox = imagettfbbox($size, 0, $fontfile, ' ');
$sbox = ($sbox[2]-$sbox[0])* $float_indice;
$angle = $angle + ($zoneX ) ;
//$angle en radian
// $angle = $angle * M_PI / 180;
$angle = deg2rad($angle);
foreach(preg_split('//u', $text) AS $t){
$px = $x+$r*cos($angle);
$py = $y+$r*sin($angle);
/*
$px = round($x+$r*cos($angle));
$py = round($y+$r*sin($angle));
*/
//Retransformation en degres pour l'affichage
$dirangle = (360-(M_PI/2+$angle)*180/M_PI+($dir?180:0))%360;
$box = imagettfbbox($size, 0, $fontfile, $t);
$dx = ($box[2]-$box[0]);
// echo "angle : ".$dirangle."<br/>";
if($angle < 2.85 && $angle > 1.80 && ($dx >= ($size -5)))
{
$dirangle = $dirangle + 7;
$dx = $dx - 3;
}elseif($angle < 1.45 && $angle > 0.80 && ($dx >= ($size -3))){
$dirangle = $dirangle + 5;
}elseif($angle < 1.77 && $angle > 1.49)
{
$dirangle = $dirangle + 5;
}
//$dirangle = $dirangle + 7;
if($dx >= ($size -1))
{
$dx = $dx -5;
}
$da = abs(asin(($dx+$sbox)/$r));
imagettftext($image, $size, $dirangle, $px , $py, $color, $fontfile, $t);
if($dir){
$angle-=$da;
}else{
$angle+=$da;
}
}
}