diff --git a/libs/pChart2.1.3/class/pDraw.class.php b/libs/pChart2.1.3/class/pDraw.class.php index 8906d7d5d00..fdffa556440 100644 --- a/libs/pChart2.1.3/class/pDraw.class.php +++ b/libs/pChart2.1.3/class/pDraw.class.php @@ -1016,17 +1016,27 @@ function drawText($X,$Y,$Text,$Format="") if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 ) { $C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa); - imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$Text); + imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$this->getEncodedText($Text)); } $C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha); - imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$Text); + imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$this->getEncodedText($Text)); $this->Shadow = $Shadow; return($TxtPos); } + function getEncodedText($text) + { + $gdinfo = gd_info(); + if (!empty($gdinfo['JIS-mapped Japanese Font Support'])) { + return mb_convert_encoding($text, "SJIS", "UTF-8"); + } + + return $text; + } + /* Draw a gradient within a defined area */ function drawGradientArea($X1,$Y1,$X2,$Y2,$Direction,$Format="") { @@ -1388,7 +1398,7 @@ function drawArrowLabel($X1,$Y1,$Text,$Format="") $this->drawArrow($X2,$Y2,$X1,$Y1,$Format); - $Size = imagettfbbox($FontSize,0,$FontName,$Text); + $Size = imagettfbbox($FontSize,0,$FontName,$this->getEncodedText($Text)); $TxtWidth = max(abs($Size[2]-$Size[0]),abs($Size[0]-$Size[6])); $TxtHeight = max(abs($Size[1]-$Size[7]),abs($Size[3]-$Size[1])); diff --git a/libs/pChart2.1.3/class/pImage.class.php b/libs/pChart2.1.3/class/pImage.class.php index 6c9d318ba81..6ad1151b697 100644 --- a/libs/pChart2.1.3/class/pImage.class.php +++ b/libs/pChart2.1.3/class/pImage.class.php @@ -97,7 +97,7 @@ function pImage($XSize,$YSize,$DataSet=NULL,$TransparentBackground=FALSE) imagealphablending($this->Picture,FALSE); imagefilledrectangle($this->Picture, 0,0,$XSize, $YSize, imagecolorallocatealpha($this->Picture, 255, 255, 255, 127)); imagealphablending($this->Picture,TRUE); - imagesavealpha($this->Picture,true); + imagesavealpha($this->Picture,true); } else { @@ -190,7 +190,7 @@ function getAngle($X1,$Y1,$X2,$Y2) /* Return the surrounding box of text area */ function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text) { - $Size = imagettfbbox($FontSize,$Angle,$FontName,$Text); + $Size = imagettfbbox($FontSize,$Angle,$FontName,$this->getEncodedText($Text)); $Width = $this->getLength($Size[0],$Size[1],$Size[2],$Size[3])+1; $Height = $this->getLength($Size[2],$Size[3],$Size[4],$Size[5])+1; @@ -205,10 +205,20 @@ function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text) return($RealPos); } + function getEncodedText($text) + { + $gdinfo = gd_info(); + if (!empty($gdinfo['JIS-mapped Japanese Font Support'])) { + return mb_convert_encoding($text, "SJIS", "UTF-8"); + } + + return $text; + } + /* Return the surrounding box of text area */ function getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text) { - $coords = imagettfbbox($FontSize, 0, $FontName, $Text); + $coords = imagettfbbox($FontSize, 0, $FontName, $this->getEncodedText($Text)); $a = deg2rad($Angle); $ca = cos($a); $sa = sin($a); $RealPos = array(); for($i = 0; $i < 7; $i += 2) @@ -247,7 +257,7 @@ function setFontProperties($Format="") if ( $FontName != NULL ) $this->FontName = $FontName; - + if ( $FontSize != NULL ) $this->FontSize = $FontSize; } @@ -332,7 +342,7 @@ function replaceImageMapTitle($OldTitle, $NewTitle) if ( $this->ImageMapStorageMode == NULL ) { return(-1); } if ( is_array($NewTitle) ) { $NewTitle = $this->removeVOIDFromArray($OldTitle, $NewTitle); } - + if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { if(!isset($_SESSION)) { return(-1); } @@ -373,7 +383,7 @@ function replaceImageMapValues($Title, $Values) if ( $this->ImageMapStorageMode == NULL ) { return(-1); } $Values = $this->removeVOIDFromArray($Title, $Values); - $ID = 0; + $ID = 0; if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { if(!isset($_SESSION)) { return(-1); } @@ -460,7 +470,7 @@ function drawAreaMirror($X,$Y,$Width,$Height,$Format="") $Picture = imagecreatetruecolor($this->XSize,$this->YSize); imagecopy($Picture,$this->Picture,0,0,0,0,$this->XSize,$this->YSize); - + for($i=1;$i<=$Height;$i++) { if ( $Y+($i-1) < $this->YSize && $Y-$i > 0 ) { imagecopymerge($Picture,$this->Picture,$X,$Y+($i-1),$X,$Y-$i,$Width,1,$StartAlpha-$AlphaStep*$i); }