--- t3lib/class.t3lib_stdgraphic.php 2010-03-02 16:33:52.000000000 +0100 +++ t3lib.new/class.t3lib_stdgraphic.php 2010-04-09 13:26:59.000000000 +0200 @@ -1282,6 +1282,11 @@ $breakWidth = $conf['breakWidth']; $breakSpace = $this->getBreakSpace($conf); + + //Bounding box is needed for total image width + if ($conf['align'] == 'right' || $conf['align'] == 'center') { + $boundingBox = $this->calcBBox($conf); + } $wordPairs = $this->getWordPairsForLineBreak($string); // Iterate through all word pairs: @@ -1291,8 +1296,10 @@ $currentWidth+= $wordWidth; $phrase.= $wordPair; } else { - // Render the current phrase that is below breakWidth: - $this->ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $phrase, $splitRendering, $sF); + //Recalc width to skip trailing blanks + $currentWidth = $this->getRenderedTextWidth(trim($phrase), $conf); + // Render the current phrase that is below breakWidth - set x position depending on alignment: + $this->ImageTTFTextWrapper($im, $fontSize, $angle, ($conf['align'] == 'right' ? $boundingBox[0] - $currentWidth : ($conf['align'] == 'center' ? ($boundingBox[0] - $currentWidth) / 2 : $x)), $y, $color, $fontFile, trim($phrase), $splitRendering, $sF); // Calculate the news height offset: $y+= $breakSpace; // Restart the phrase: @@ -1302,7 +1309,7 @@ } // Render the remaining phrase: if ($currentWidth) { - $this->ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $phrase, $splitRendering, $sF); + $this->ImageTTFTextWrapper($im, $fontSize, $angle, ($conf['align'] == 'right' ? $boundingBox[0] - $currentWidth : ($conf['align'] == 'center' ? ($boundingBox[0] - $currentWidth) / 2 : $x)), $y, $color, $fontFile, $phrase, $splitRendering, $sF); } } else { $this->ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $sF);