Esempio n. 1
0
 /**
  * Sets the font options.
  *
  * The $font array may have the following entries:
  *
  * 'ttf' = the .ttf file (either the basename, filename or full path)
  * If 'ttf' is specified, then the following can be specified
  *
  * 'size' = size in pixels
  *
  * 'angle' = the angle with which to write the text
  *
  * @param array $font The font options.
  */
 function setFont($fontOptions)
 {
     parent::setFont($fontOptions);
     if (isset($this->_font['ttf'])) {
         $this->_font['file'] = str_replace('\\', '/', Image_Canvas_Tool::fontMap($this->_font['ttf']));
     } elseif (!isset($this->_font['font'])) {
         $this->_font['font'] = 1;
     }
     if (!isset($this->_font['color'])) {
         $this->_font['color'] = 'black';
     }
     if (isset($this->_font['angle']) && $this->_font['angle'] === false) {
         $this->_font['angle'] = 0;
     }
 }
Esempio n. 2
0
 /**
  * Sets the font options.
  *
  * The $font array may have the following entries:
  *
  * 'name'    The name of the font. This name must either be supported
  * natively by the canvas or mapped to a font using the font-mapping scheme
  *
  * 'size'     Size in pixels
  *
  * 'angle'     The angle with which to write the text
  *
  * @param array $fontOptions The font options.
  */
 function setFont($fontOptions)
 {
     $this->_font = $fontOptions;
     if (!isset($this->_font['color'])) {
         $this->_font['color'] = 'black';
     }
     if (!isset($this->_font['angle']) || $this->_font['angle'] === false) {
         $this->_font['angle'] = 0;
     }
     if (isset($this->_font['angle'])) {
         if ($this->_font['angle'] > 45 && $this->_font['angle'] < 135 || $this->_font['angle'] > 225 && $this->_font['angle'] < 315) {
             $this->_font['vertical'] = true;
         }
     }
     if (!isset($this->_font['file']) && isset($this->_font['name'])) {
         include_once 'Image/Canvas/Tool.php';
         $this->_font['file'] = Image_Canvas_Tool::fontMap($this->_font['name']);
     }
 }