Açıklama Yok

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Writer\HTML\Style;
  18. use PhpOffice\PhpWord\Style\Font as FontStyle;
  19. /**
  20. * Font style HTML writer
  21. *
  22. * @since 0.10.0
  23. */
  24. class Font extends AbstractStyle
  25. {
  26. /**
  27. * Write style
  28. *
  29. * @return string
  30. */
  31. public function write()
  32. {
  33. $style = $this->getStyle();
  34. if (!$style instanceof FontStyle) {
  35. return '';
  36. }
  37. $css = array();
  38. $font = $style->getName();
  39. $size = $style->getSize();
  40. $color = $style->getColor();
  41. $fgColor = $style->getFgColor();
  42. $underline = $style->getUnderline() != FontStyle::UNDERLINE_NONE;
  43. $lineThrough = $style->isStrikethrough() || $style->isDoubleStrikethrough();
  44. $css['font-family'] = $this->getValueIf($font !== null, "'{$font}'");
  45. $css['font-size'] = $this->getValueIf($size !== null, "{$size}pt");
  46. $css['color'] = $this->getValueIf($color !== null, "#{$color}");
  47. $css['background'] = $this->getValueIf($fgColor != '', $fgColor);
  48. $css['font-weight'] = $this->getValueIf($style->isBold(), 'bold');
  49. $css['font-style'] = $this->getValueIf($style->isItalic(), 'italic');
  50. $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'italic');
  51. $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'super');
  52. $css['vertical-align'] = $this->getValueIf($style->isSubScript(), 'sub');
  53. $css['text-decoration'] = '';
  54. $css['text-decoration'] .= $this->getValueIf($underline, 'underline ');
  55. $css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through ');
  56. return $this->assembleCss($css);
  57. }
  58. }