Writes a text on the image.

@param string $text
@param float[] $point
@param float $size
@param float $angle
@param string $font
@param int $maxwidth
@param float[] $rgbAr
@param int $textAlignment
@throws ImageUtilException
320750
public function writeText($text, $point, $size, $angle, $font, $maxwidth = 0, $rgbAr = null, $textAlignment = 1)
    {
        if (!is_readable($font)) {
            throw new ImageUtilException('Error: The specified font not found');
        }

        if (!is_array($rgbAr)) {
            $rgbAr = [0, 0, 0];
        }

        $color = imagecolorallocate($this->image, $rgbAr[0], $rgbAr[1], $rgbAr[2]);

        // Determine the line break if required.
        if (($maxwidth > 0) && ($angle == 0)) {
            $words = explode(' ', $text);
            $lines = [$words[0]];
            $currentLine = 0;

            $numberOfWords = count($words);
            for ($i = 1; $i < $numberOfWords; $i++) {
                $lineSize = imagettfbbox($size, 0, $font, $lines[$currentLine] . ' ' . $words[$i]);
                if ($lineSize[2] - $lineSize[0] < $maxwidth) {
                    $lines[$currentLine] .= ' ' . $words[$i];
                } else {
                    $currentLine++;
                    $lines[$currentLine] = $words[$i];
                }
            }
        } else {
            $lines = [$text];
        }

        $curX = $point[0];
        $curY = $point[1];

        foreach ($lines as $text) {
            $bbox = imagettfbbox($size, $angle, $font, $text);

            switch ($textAlignment) {
                case TextAlignment::RIGHT:
                    $curX = $point[0] - abs($bbox[2] - $bbox[0]);
                    break;

                case TextAlignment::CENTER:
                    $curX = $point[0] - (abs($bbox[2] - $bbox[0]) / 2);
                    break;
            }

            imagettftext($this->image, $size, $angle, $curX, $curY, $color, $font, $text);

            $curY += ($size * 1.35);
        }
    }
371454
function drawText( &$font, $textColor, $text, $x, $y, $angle,
                       $imageObject = null )
    {
        if ( !$font )
        {
            eZDebug::writeWarning( 'Cannot render text, no font is set', __METHOD__ );
            return false;
        }
        if ( !$textColor )
        {
            eZDebug::writeWarning( 'Cannot render text, no text color is set', __METHOD__ );
            return false;
        }
        if ( is_string( $textColor ) )
            $textColor = $this->color( $textColor );
        if ( $textColor === null )
        {
            eZDebug::writeWarning( 'Cannot render text, invalid text color', __METHOD__ );
            return false;
        }

        $x += $font->xAdjustment();
        $y += $font->yAdjustment();

        if ( $imageObject === null )
            $imageObject = $this->ImageObject;

        ImageTTFText( $imageObject, $font->pointSize(), $angle, $x, $y,
                      $textColor, $font->realFile(), $text );
    }
997088
public function drawText($text, $x, $y, $charEncoding = 'WINDOWS-1252')
    {
        $this->convertCoordinatesFromUserSpace($x, $y);
        $y -= $this->getFontSize();
        return parent::drawText($text, $x, $y, $charEncoding);
    }
1316461
public function write(&$text)
    {
        // All: Add the action if left empty
        if (preg_match_all('#<\s*form.*?action=""#im', $text, $matches, PREG_SET_ORDER)) {
            $view   = $this->getTemplate()->getView();
            $state  = $view->getModel()->getState();
            $action = $view->getRoute(http_build_query($state->getData($state->isUnique())));
            
            foreach ($matches as $match) {
                $str  = str_replace('action=""', 'action="'.$action.'"', $match[0]);
                $text = str_replace($match[0], $str, $text);
            }
        }
        
        // POST : Add token
        $matches = array();
        preg_match_all('/(<form.*method="post".*>)/i', $text, $matches, PREG_SET_ORDER);
       
        foreach ($matches as $match) {
            $input = PHP_EOL.'<input type="hidden" name="'.$this->_tokenName().'" value="'.$this->_tokenValue().'" />';
            $text = str_replace($match[0], $match[0].$input, $text, $count);
        }
       
        // GET : Add token to .-anahita-grid forms
        $matches = array();
        preg_match_all('#(<\s*?form\s+?.*?class=(?:\'|")[^\'"]*?-anahita-grid.*?(?:\'|").*?)#im', $text, $matches, PREG_SET_ORDER);
        
        foreach ($matches as $match) {
            $input = ' data-token-name="'.$this->_tokenName().'" data-token-value="'.$this->_tokenValue().'"';
            $text= str_replace($match[0], $match[0].$input, $text, $count);
        }
        
        // GET : Add query params
        $matches = array();
        if (preg_match_all('#<form.*action=".*\?(.*)".*method="get".*>#iU', $text, $matches)) {
            foreach ($matches[1] as $key => $query) {
                parse_str(str_replace('&amp;', '&', $query), $query);
                
                $input = $this->_renderQuery($query);
                $text  = str_replace($matches[0][$key], $matches[0][$key].$input, $text);
            }
        }
        
        return $this;
    }
520482
public function do_text(
        $text,
        $offsetX = 0,
        $offsetY = 0,
        $opacity = 1.0,
        $color = 0x000000,
        $size = 12,
        $font_file = null
    ) {
        $textColor = imagecolorallocatealpha($this->_image, ($color >> 16) & 0xFF, ($color >> 8) & 0xFF,
            $color & 0xFF, abs(1 - $opacity) * 127);
        if ($font_file) {
            imagettftext($this->_image, $size, 0, $offsetX, $offsetY, $textColor, $this->alias->resolve($font_file), $text);
        } else {
            imagestring($this->_image, $size, $offsetX, $offsetY, $text, $textColor);
        }

        return $this;
    }
1040202
def write_text(self, text):
        
        text_width = max(self.width - self.current_indent, 11)
        indent = ' ' * self.current_indent
        self.write(wrap_text(text, text_width,
                             initial_indent=indent,
                             subsequent_indent=indent,
                             preserve_paragraphs=True))
        self.write('\n')
841591
public function addText($text)
    {
        $currentDescription = $this->project->getDescription();
        if ($currentDescription === null) {
            $this->project->setDescription($text);
        } else {
            $this->project->setDescription($currentDescription . $text);
        }
    }
1130825
private function header($text)
    {
        $this->io()->write($this->line(strlen($text)));
        $this->io()->write($this->color($text, $this->getConfig('fg-header')));
        $this->io()->write($this->line(strlen($text)));
    }
38848
public function drawText($X, $Y, $Text, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
        $G = isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
        $B = isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
        $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
        $Align = isset($Format["Align"]) ? $Format["Align"] : TEXT_ALIGN_BOTTOMLEFT;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
        $FontName = isset($Format["FontName"]) ? $this->loadFont($Format["FontName"], 'fonts') : $this->FontName;
        $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
        $ShowOrigine = isset($Format["ShowOrigine"]) ? $Format["ShowOrigine"] : false;
        $TOffset = isset($Format["TOffset"]) ? $Format["TOffset"] : 2;
        $DrawBox = isset($Format["DrawBox"]) ? $Format["DrawBox"] : false;
        $BorderOffset = isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 6;
        $BoxRounded = isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : false;
        $RoundedRadius = isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 6;
        $BoxR = isset($Format["BoxR"]) ? $Format["BoxR"] : 255;
        $BoxG = isset($Format["BoxG"]) ? $Format["BoxG"] : 255;
        $BoxB = isset($Format["BoxB"]) ? $Format["BoxB"] : 255;
        $BoxAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
        $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
        $BoxBorderR = isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
        $BoxBorderG = isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
        $BoxBorderB = isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
        $BoxBorderAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
        $NoShadow = isset($Format["NoShadow"]) ? $Format["NoShadow"] : false;

        $Shadow = $this->Shadow;
        if ($NoShadow) {
            $this->Shadow = false;
        }

        if ($BoxSurrounding != "") {
            $BoxBorderR = $BoxR - $BoxSurrounding;
            $BoxBorderG = $BoxG - $BoxSurrounding;
            $BoxBorderB = $BoxB - $BoxSurrounding;
            $BoxBorderAlpha = $BoxAlpha;
        }

        if ($ShowOrigine) {
            $MyMarkerSettings = [
                "R" => 255,
                "G" => 0,
                "B" => 0,
                "BorderR" => 255,
                "BorderB" => 255,
                "BorderG" => 255,
                "Size" => 4
            ];
            $this->drawRectangleMarker($X, $Y, $MyMarkerSettings);
        }

        $TxtPos = $this->getTextBox($X, $Y, $FontName, $FontSize, $Angle, $Text);

        if ($DrawBox && ($Angle == 0 || $Angle == 90 || $Angle == 180 || $Angle == 270)) {
            $T[0]["X"] = 0;
            $T[0]["Y"] = 0;
            $T[1]["X"] = 0;
            $T[1]["Y"] = 0;
            $T[2]["X"] = 0;
            $T[2]["Y"] = 0;
            $T[3]["X"] = 0;
            $T[3]["Y"] = 0;
            if ($Angle == 0) {
                $T[0]["X"] = -$TOffset;
                $T[0]["Y"] = $TOffset;
                $T[1]["X"] = $TOffset;
                $T[1]["Y"] = $TOffset;
                $T[2]["X"] = $TOffset;
                $T[2]["Y"] = -$TOffset;
                $T[3]["X"] = -$TOffset;
                $T[3]["Y"] = -$TOffset;
            }

            $X1 = min($TxtPos[0]["X"], $TxtPos[1]["X"], $TxtPos[2]["X"], $TxtPos[3]["X"]) - $BorderOffset + 3;
            $Y1 = min($TxtPos[0]["Y"], $TxtPos[1]["Y"], $TxtPos[2]["Y"], $TxtPos[3]["Y"]) - $BorderOffset;
            $X2 = max($TxtPos[0]["X"], $TxtPos[1]["X"], $TxtPos[2]["X"], $TxtPos[3]["X"]) + $BorderOffset + 3;
            $Y2 = max($TxtPos[0]["Y"], $TxtPos[1]["Y"], $TxtPos[2]["Y"], $TxtPos[3]["Y"]) + $BorderOffset - 3;

            $X1 = $X1 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
            $Y1 = $Y1 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
            $X2 = $X2 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
            $Y2 = $Y2 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];

            $Settings = [
                "R" => $BoxR,
                "G" => $BoxG,
                "B" => $BoxB,
                "Alpha" => $BoxAlpha,
                "BorderR" => $BoxBorderR,
                "BorderG" => $BoxBorderG,
                "BorderB" => $BoxBorderB,
                "BorderAlpha" => $BoxBorderAlpha
            ];

            if ($BoxRounded) {
                $this->drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $RoundedRadius, $Settings);
            } else {
                $this->drawFilledRectangle($X1, $Y1, $X2, $Y2, $Settings);
            }
        }

        $X = $X - $TxtPos[$Align]["X"] + $X;
        $Y = $Y - $TxtPos[$Align]["Y"] + $Y;

        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
            );
        }

        $C_TextColor = $this->AllocateColor($this->Picture, $R, $G, $B, $Alpha);
        imagettftext($this->Picture, $FontSize, $Angle, $X, $Y, $C_TextColor, $FontName, $Text);

        $this->Shadow = $Shadow;

        return $TxtPos;
    }
1091421
public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false)
    {
        if ($x==null) $x = $this->GetX();
        if ($y==null) $y = $this->GetY();
        $textrendermode = $this->textrendermode;
        $textstrokewidth = $this->textstrokewidth;
        $this->setTextRenderingMode(0, true, false);
        $this->SetXY($x, $y);
        $this->MultiCell($w, 0, $txt, $border, $align, $fill);
        // restore previous rendering mode
        $this->textrendermode = $textrendermode;
        $this->textstrokewidth = $textstrokewidth;
    }
845977
private function writeLine($text, $indent = 0)
    {
        $indent = strlen($text) + $indent;
        $format = '%'.$indent.'s';

        $this->reference .= sprintf($format, $text).PHP_EOL;
    }
854240
public function writeText($value)
    {
        if (is_array($value)) {
            foreach ($value as $attrValue) {
                $this->context->text($attrValue);
            }
        } else {
            $this->context->text($value);
        }
    }
329787
public static function TTFBox($font, $text, $size, $angle = 0)
    {
        $box = imagettfbbox($size, $angle, $font, $text);

        return array(
            'width'  => abs($box[2] - $box[0]),
            'height' => abs($box[3] - $box[5]),
        );
    }
56963
public function setText(string $text): void
    {
        $this->text = $text;

        if ( ! is_null($this->encode)) {
            $text = $this->encode->convert($text);

            // remember the conversion
            $this->convertedText = $text;
        }
    }
746431
public function watermarkText($text, $pos = 0, $fontSize = 14, array $color = null, $font = null, $shadow = true)
    {
        if (!$color)
        {
            $color = [255, 255, 255, 0, 0, 0];
        }

        $font = (!$font) ? $this->fontFile : $font;

        if (!$this->newImage || !is_resource($this->newImage))
        {
            $this->newImage = $this->sourceImage;
            $sourceWidth    = $this->source['width'];
            $sourceHeight   = $this->source['height'];
        }
        else
        {
            $sourceWidth    = imagesx($this->newImage);
            $sourceHeight   = imagesy($this->newImage);
        }

        $textImage   = imagecreatetruecolor($sourceWidth, $sourceHeight);
        $textColor   = imagecolorallocate($textImage, $color[0], $color[1], $color[2]);
        $shadowColor = imagecolorallocate($textImage, $color[3], $color[4], $color[5]);

        // get 8 corners coordinates of the text watermark
        $size        = imagettfbbox($fontSize, 0, $font, $text);
        $textWidth   = $size[4];
        $textHeight  = abs($size[7]);

        $position    = $this->position($pos, $sourceWidth, $sourceHeight, $textWidth + 4, $textHeight, true, $fontSize);

        $posX = $position['x'];
        $posY = $position['y'];

        imagealphablending($textImage, true);
        imagesavealpha($textImage, true);

        imagecopymerge($textImage, $this->newImage, 0, 0, 0, 0, $sourceWidth, $sourceHeight, 100);

        if ($shadow)
        {
            imagettftext($textImage, $fontSize, 0, $posX + 1, $posY + 1, $shadowColor, $font, $text);
        }

        imagettftext($textImage, $fontSize, 0, $posX, $posY, $textColor, $font, $text);

        $this->newImage = $textImage;

        return $this;
    }
1340314
def _writeText(self, image, text, pos):
        """"""
        offset = 0
        x, y = pos

        for c in text:
            # Write letter
            c_size = self.font.getsize(c)
            c_image = Image.new('RGBA', c_size, (0, 0, 0, 0))
            c_draw = ImageDraw.Draw(c_image)
            c_draw.text((0, 0), c, font=self.font, fill=(0, 0, 0, 255))

            # Transform
            c_image = self._rndLetterTransform(c_image)

            # Paste onto image
            image.paste(c_image, (x+offset, y), c_image)
            offset += c_size[0]
57342
public function setTextColor($r, $g, $b)
    {
        $this->ink['text'] = imagecolorallocate($this->im, $r, $g, $b);
    }