Ejemplo n.º 1
0
 static function createForText($text, &$font, $widthAdjustment, $heightAdjustment, $angle, $absoluteWidth = false, $absoluteHeight = false)
 {
     $Return = false;
     if (!$font instanceof eZImageFont) {
         return $Return;
     }
     if (!function_exists('ImageTTFBBox')) {
         eZDebug::writeError('ImageTTFBBox function not in PHP, check PHP compilation', 'ezimagetextlayer.php');
         return $Return;
     }
     $bbox = ImageTTFBBox($font->pointSize(), $angle, $font->realFile(), $text);
     if (!$bbox) {
         return $Return;
     }
     $xmin = min($bbox[0], $bbox[2], $bbox[4], $bbox[6]);
     $xmax = max($bbox[0], $bbox[2], $bbox[4], $bbox[6]);
     $ymin = min($bbox[1], $bbox[3], $bbox[5], $bbox[7]);
     $ymax = max($bbox[1], $bbox[3], $bbox[5], $bbox[7]);
     $width = abs($xmax - $xmin);
     $height = abs($ymax - $ymin);
     $width += $widthAdjustment;
     $height += $heightAdjustment;
     if ($absoluteWidth !== false) {
         $width = $absoluteWidth;
     }
     if ($absoluteHeight !== false) {
         $height = $absoluteHeight;
     }
     $layer = new eZImageTextLayer(null, null, $width, $height, $font, $bbox, $text, $angle);
     $layer->create($width, $height, null);
     return $layer;
 }