/**
* @param Thumbnail $thumbnail
* @return void
* @throws Exception\NoThumbnailAvailableException
*/
public function refresh(Thumbnail $thumbnail)
{
$temporaryPathAndFilename = null;
try {
$filename = pathinfo($thumbnail->getOriginalAsset()->getResource()->getFilename(), PATHINFO_FILENAME);
$temporaryLocalCopyFilename = $thumbnail->getOriginalAsset()->getResource()->createTemporaryLocalCopy();
$temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('ProcessedFontThumbnail-') . '.' . $filename . '.jpg';
$width = 1000;
$height = 1000;
$im = imagecreate($width, $height);
$red = imagecolorallocate($im, 0xff, 0xff, 0xff);
$black = imagecolorallocate($im, 0x0, 0x0, 0x0);
imagefilledrectangle($im, 0, 0, $width, $height, $red);
imagefttext($im, 48, 0, 80, 150, $black, $temporaryLocalCopyFilename, 'Neos Font Preview');
imagefttext($im, 32, 0, 80, 280, $black, $temporaryLocalCopyFilename, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
imagefttext($im, 32, 0, 80, 360, $black, $temporaryLocalCopyFilename, 'abcdefghijklmopqrstuvwxyz');
imagefttext($im, 32, 0, 80, 440, $black, $temporaryLocalCopyFilename, '1234567890');
imagefttext($im, 32, 0, 80, 560, $black, $temporaryLocalCopyFilename, '+ " * ç % & / ( ) = ? @ €');
imagejpeg($im, $temporaryPathAndFilename);
$resource = $this->resourceManager->importResource($temporaryPathAndFilename);
$processedImageInfo = $this->resize($thumbnail, $resource);
$thumbnail->setResource($processedImageInfo['resource']);
$thumbnail->setWidth($processedImageInfo['width']);
$thumbnail->setHeight($processedImageInfo['height']);
Files::unlink($temporaryPathAndFilename);
} catch (\Exception $exception) {
Files::unlink($temporaryPathAndFilename);
$filename = $thumbnail->getOriginalAsset()->getResource()->getFilename();
$sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1();
$message = sprintf('Unable to generate thumbnail for the given font (filename: %s, SHA1: %s)', $filename, $sha1);
throw new Exception\NoThumbnailAvailableException($message, 1433109653, $exception);
}
}