/** * Set text formatting option * * Set a text formatting option. The names of the options are the same used * in the PCSS files and need to be translated by the driver to the proper * backend calls. * * * @param string $type * @param mixed $value * @return void */ public function setTextFormatting($type, $value) { switch ($type) { case 'font-style': if ($value === 'oblique' || $value === 'italic') { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] | self::FONT_OBLIQUE); } else { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] & ~self::FONT_OBLIQUE); } break; case 'font-weight': if ($value === 'bold' || $value === 'bolder') { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] | self::FONT_BOLD); } else { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] & ~self::FONT_BOLD); } break; case 'font-family': $this->trySetFont($value, $this->currentFont['style']); break; case 'font-size': $this->currentFont['size'] = ezcDocumentPcssMeasure::create($value)->get('pt'); $this->document->setFontSize($this->currentFont['size']); break; case 'color': $this->document->setTextColor($value['red'] * 255, $value['green'] * 255, $value['blue'] * 255); default: // @todo: Error reporting. } }
/** * Set text formatting option * * Set a text formatting option. The names of the options are the same used * in the PCSS files and need to be translated by the driver to the proper * backend calls. * * * @param string $type * @param mixed $value * @return void */ public function setTextFormatting($type, $value) { switch ($type) { case 'font-style': if ($value === 'oblique' || $value === 'italic') { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] | self::FONT_OBLIQUE); } else { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] & ~self::FONT_OBLIQUE); } break; case 'font-weight': if ($value === 'bold' || $value === 'bolder') { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] | self::FONT_BOLD); } else { $this->trySetFont($this->currentFont['name'], $this->currentFont['style'] & ~self::FONT_BOLD); } break; case 'font-family': $this->trySetFont($value, $this->currentFont['style']); break; case 'font-size': $this->currentFont['size'] = $this->mmToPixel((double) $value); $this->document->setFontSize($this->currentFont['size']); break; default: // @TODO: Error reporting. } }