You are here

protected function GDOperationTrait::imagettfbboxWrapper in Image Effects 8.2

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::imagettfbboxWrapper()
  2. 8 src/Plugin/ImageToolkit/Operation/gd/GDOperationTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\GDOperationTrait::imagettfbboxWrapper()

Wrapper of imagettfbbox().

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

Parameters

float $size: The font size.

float $angle: The angle in degrees.

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

string $text: The string to be measured.

Return value

int[]|false Array with 8 elements representing four points making the bounding box of the text on success and FALSE on error.

See also

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

2 calls to GDOperationTrait::imagettfbboxWrapper()
TextToWrapper::getTextHeightInfo in src/Plugin/ImageToolkit/Operation/gd/TextToWrapper.php
Return the height and basepoint of a text using TrueType fonts.
TextToWrapper::getTextWidth in src/Plugin/ImageToolkit/Operation/gd/TextToWrapper.php
Return the width of a text using TrueType fonts.

File

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

Class

GDOperationTrait
Trait for GD image toolkit operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation\gd

Code

protected function imagettfbboxWrapper($size, $angle, $fontfile, $text) {
  if (function_exists('imagettfbbox')) {
    return imagettfbbox($size, $angle, $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 imagettfbbox() PHP function is not available, and image effects using fonts cannot be executed");
  }
}