You are here

protected function GDOperationTrait::imagettftextWrapper in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/gd/GDOperationTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\GDOperationTrait::imagettftextWrapper()
  2. 8.2 src/Plugin/ImageToolkit/Operation/gd/GDOperationTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\GDOperationTrait::imagettftextWrapper()

Wrapper of imagettftext().

If imagettftext() is missing, throw an exception instead of failing fatally.

Parameters

resource $image: An image resource.

float $size: The font size.

float $angle: The angle in degrees.

int $x: The coordinates given by x and y will define the basepoint of the first character (roughly the lower-left corner of the character).

int $y: The y-ordinate. This sets the position of the fonts baseline, not the very bottom of the character.

int $color: The color index.

string $fontfile: The path to the TrueType font to use.

string $text: The text string in UTF-8 encoding.

Return value

int[] An array with 8 elements representing four points making the bounding box of the text.

See also

http://php.net/manual/en/function.imagettftext.php

1 call to GDOperationTrait::imagettftextWrapper()
TextOverlay::execute in src/Plugin/ImageToolkit/Operation/gd/TextOverlay.php
Performs the actual manipulation on the image.

File

src/Plugin/ImageToolkit/Operation/gd/GDOperationTrait.php, line 182

Class

GDOperationTrait
Trait for GD image toolkit operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation\gd

Code

protected function imagettftextWrapper($image, $size, $angle, $x, $y, $color, $fontfile, $text) {
  if (function_exists('imagettftext')) {
    return imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);
  }
  else {

    // @todo \InvalidArgumentException is incorrect, but other exceptions
    // would not be managed by toolkits that implement ImageToolkitBase.
    // Change to \RuntimeException when #2583041 is committed.
    throw new \InvalidArgumentException("The imagettftext() PHP function is not available, and image effects using fonts cannot be executed");
  }
}