pChart 2.x forum
http://wiki.pchart.net/forum/

Problem with drawtext function
http://wiki.pchart.net/forum/viewtopic.php?f=5&t=30044
Page 1 of 1

Author:  bcit6k [ Mon Nov 19, 2012 1:11 pm ]
Post subject:  Problem with drawtext function

Dear programmer,

we found an main Problem in your drawtext function.

the problem ist that wehen you draw 2 strings like:

string1:3
string2:Testg

the 3 and the T are not on the same high. So its allways looks like the 3 is deeper than the T.

For thsi we found an fix:

File:pImage.class.php

function getTextBox (row 209)

Code:
$coords = imagettfbbox($FontSize, 0, $FontName, $Text);
     $coords2 = imagettfbbox($FontSize, 0, $FontName, $Text.'3Bg');

     $a = deg2rad($Angle); $ca = cos($a); $sa = sin($a); $RealPos = array();
     for($i = 0; $i < 7; $i += 2)
      {
       $RealPos[$i/2]["X"] = $X + round($coords[$i] * $ca + $coords[$i+1] * $sa);
       $RealPos[$i/2]["Y"] = $Y + round($coords2[$i+1] * $ca - $coords2[$i] * $sa);
      }

we insert cords2 for the height calculation the other for the width.

this works but it isnt beautiful.

mybe you can fix ths problem better

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/