/**
  * @param array $attrs
  * @return array {@example array("stroke" => array("attr" => "value"), "fill" => "fill_color"))
  */
 public function buildGraphicStyles(array $attrs)
 {
     if (empty($attrs['stroke_width']) || $attrs['stroke_color'] == 'none') {
         $stroke_style = null;
     } else {
         $stroke_color = ColorParser::parse($attrs['stroke_color']);
         if ($attrs['stroke_dash'] === 'none') {
             $stroke_dash = 0;
         } else {
             $stroke_dash = $attrs['stroke_dash'];
         }
         $stroke_style = array('width' => $attrs['stroke_width'], 'color' => $stroke_color, 'dash' => $stroke_dash);
     }
     if (array_key_exists('fill_color', $attrs) && $attrs['fill_color'] !== 'none') {
         $fill_color = ColorParser::parse($attrs['fill_color']);
     } else {
         $fill_color = null;
     }
     return array('stroke' => $stroke_style, 'fill' => $fill_color);
 }
Exemple #2
0
 /**
  * @param array $attrs
  * @return array
  */
 public function buildTextStyles(array $attrs)
 {
     $font_style = array();
     foreach ($attrs['font_style'] ?: array() as $style) {
         $font_style[] = self::$pdf_font_style[$style];
     }
     if (array_key_exists('line_height', $attrs)) {
         $line_height = $attrs['line_height'];
     } else {
         $line_height = self::$pdf_default_line_height;
     }
     if (array_key_exists('letter_spacing', $attrs)) {
         $letter_spacing = $attrs['letter_spacing'];
     } else {
         $letter_spacing = 0;
     }
     if (array_key_exists('align', $attrs)) {
         $align = $attrs['align'];
     } else {
         $align = 'left';
     }
     if (array_key_exists('valign', $attrs)) {
         $valign = $attrs['valign'];
     } else {
         $valign = 'top';
     }
     return array('font_size' => $attrs['font_size'], 'font_family' => Font::getFontName($attrs['font_family']), 'font_style' => implode('', $font_style), 'color' => ColorParser::parse($attrs['color']), 'align' => self::$pdf_text_align[$align], 'valign' => self::$pdf_text_valign[$valign], 'line_height' => $line_height, 'letter_spacing' => $letter_spacing);
 }