src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
function addText($text, $font, $size, $color, $x, $y, $angle = 0)
    {
        global $HTTP_SERVER_VARS;

        if (substr($font, 0, 1) == DIRECTORY_SEPARATOR || (substr($font, 1, 1) == ":" && (substr($font, 2, 1) == "\\" || substr($font, 2, 1) == "/")))
        {
            $prepath = '';
        }
        else
        {
            $prepath = substr($HTTP_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos($HTTP_SERVER_VARS['SCRIPT_FILENAME'], DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR;
        }
        $text = $this->_iso2uni($text);
        if (is_string($x) || is_string($y))
        {
            $textsize = imagettfbbox($size, $angle, $prepath . $font, $text);
            $textwidth = abs($textsize[2]);
            $textheight = abs($textsize[7]);
            list($xalign, $xalign_offset) = explode(" ", $x);
            list($yalign, $yalign_offset) = explode(" ", $y);
        }
        if (is_string($x))
        {
            switch ($xalign)
            {
                case 'left':
                    $x = 0 + $xalign_offset;
                    break;

                case 'right':
                    $x = ($this->_img['main']['width'] - $textwidth) + $xalign_offset;
                    break;

                case 'middle':
                case 'center':
                    $x = (($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset;
                    break;
            }
        }
        if (is_string($y))
        {
            switch ($yalign)
            {
                case 'top':
                    $y = (0 + $textheight) + $yalign_offset;
                    break;

                case 'bottom':
                    $y = ($this->_img['main']['height']) + $yalign_offset;
                    break;

                case 'middle':
                case 'center':
                    $y = ((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset;
                    break;
            }
        }
        imagettftext($this->_img['main']['resource'], $size, $angle, $x, $y, $this->_hexToPHPColor($color), $prepath . $font, $text);
        return true;
    }
function addText($text, $font, $size, $color, $x, $y, $angle = 0)
    {
        global $HTTP_SERVER_VARS;

        if (substr($font, 0, 1) == DIRECTORY_SEPARATOR || (substr($font, 1, 1) == ":" && (substr($font, 2, 1) == "\\" || substr($font, 2, 1) == "/")))
        {
            $prepath = '';
        }
        else
        {
            $prepath = substr($HTTP_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos($HTTP_SERVER_VARS['SCRIPT_FILENAME'], DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR;
        }
        $text = $this->_iso2uni($text);
        if (is_string($x) || is_string($y))
        {
            $textsize = imagettfbbox($size, $angle, $prepath . $font, $text);
            $textwidth = abs($textsize[2]);
            $textheight = abs($textsize[7]);
            list($xalign, $xalign_offset) = explode(" ", $x);
            list($yalign, $yalign_offset) = explode(" ", $y);
        }
        if (is_string($x))
        {
            switch ($xalign)
            {
                case 'left':
                    $x = 0 + $xalign_offset;
                    break;

                case 'right':
                    $x = ($this->_img['main']['width'] - $textwidth) + $xalign_offset;
                    break;

                case 'middle':
                case 'center':
                    $x = (($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset;
                    break;
            }
        }
        if (is_string($y))
        {
            switch ($yalign)
            {
                case 'top':
                    $y = (0 + $textheight) + $yalign_offset;
                    break;

                case 'bottom':
                    $y = ($this->_img['main']['height']) + $yalign_offset;
                    break;

                case 'middle':
                case 'center':
                    $y = ((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset;
                    break;
            }
        }
        imagettftext($this->_img['main']['resource'], $size, $angle, $x, $y, $this->_hexToPHPColor($color), $prepath . $font, $text);
        return true;
    }
function addText ( $ text , $ font , $ size , $ color , $ x , $ y , $ angle = 0 ) { global $ HTTP_SERVER_VARS ; if ( substr ( $ font , 0 , 1 ) == DIRECTORY_SEPARATOR || ( substr ( $ font , 1 , 1 ) == ":" && ( substr ( $ font , 2 , 1 ) == "\\" || substr ( $ font , 2 , 1 ) == "/" ) ) ) { $ prepath = '' ; } else { $ prepath = substr ( $ HTTP_SERVER_VARS [ 'SCRIPT_FILENAME' ] , 0 , strrpos ( $ HTTP_SERVER_VARS [ 'SCRIPT_FILENAME' ] , DIRECTORY_SEPARATOR ) ) . DIRECTORY_SEPARATOR ; } $ text = $ this -> _iso2uni ( $ text ) ; if ( is_string ( $ x ) || is_string ( $ y ) ) { $ textsize = imagettfbbox ( $ size , $ angle , $ prepath . $ font , $ text ) ; $ textwidth = abs ( $ textsize [ 2 ] ) ; $ textheight = abs ( $ textsize [ 7 ] ) ; list ( $ xalign , $ xalign_offset ) = explode ( " " , $ x ) ; list ( $ yalign , $ yalign_offset ) = explode ( " " , $ y ) ; } if ( is_string ( $ x ) ) { switch ( $ xalign ) { case 'left' : $ x = 0 + $ xalign_offset ; break ; case 'right' : $ x = ( $ this -> _img [ 'main' ] [ 'width' ] - $ textwidth ) + $ xalign_offset ; break ; case 'middle' : case 'center' : $ x = ( ( $ this -> _img [ 'main' ] [ 'width' ] - $ textwidth ) / 2 ) + $ xalign_offset ; break ; } } if ( is_string ( $ y ) ) { switch ( $ yalign ) { case 'top' : $ y = ( 0 + $ textheight ) + $ yalign_offset ; break ; case 'bottom' : $ y = ( $ this -> _img [ 'main' ] [ 'height' ] ) + $ yalign_offset ; break ; case 'middle' : case 'center' : $ y = ( ( ( $ this -> _img [ 'main' ] [ 'height' ] - $ textheight ) / 2 ) + $ textheight ) + $ yalign_offset ; break ; } } imagettftext ( $ this -> _img [ 'main' ] [ 'resource' ] , $ size , $ angle , $ x , $ y , $ this -> _hexToPHPColor ( $ color ) , $ prepath . $ font , $ text ) ; return true ; }
Writes text over the image

only TTF fonts are supported at the moment

$x:<br>
You can also use the following keywords ('left', 'center' or 'middle', 'right').<br>
Additionally you can specify an offset in pixel with the keywords like this 'left +10'.<br>
(default = 0)

$y:<br>
You can also use the following keywords ('top', 'center' or 'middle', 'bottom').<br>
Additionally you can specify an offset in pixel with the keywords like this 'bottom -10'.<br>
(default = 0)

@param string $text text to be generated.
@param string $font TTF fontfile to be used. (relative paths are ok).
@param integer $size textsize.
@param string $color textcolor in hexformat (e.g. '#FF0000').
@param string|integer $x horizontal postion in pixel.
@param string|integer $y vertical postion in pixel.
@param integer $angle rotation of the text.
Writes text over the image