fixed HTML superscript, and added allcaps, smallcaps, and letter-spacing

This commit is contained in:
troosan 2017-11-05 00:03:06 +01:00
parent 601a2b6ec6
commit 03d4a36b9b
3 changed files with 15 additions and 3 deletions

View File

@ -164,6 +164,8 @@ class Text extends AbstractElement
if ($pStyleIsObject) {
$styleWriter = new ParagraphStyleWriter($paragraphStyle);
$style = $styleWriter->write();
} elseif (is_string($paragraphStyle)) {
$style = $paragraphStyle;
}
if ($style) {
$attribute = $pStyleIsObject ? 'style' : 'class';
@ -186,6 +188,8 @@ class Text extends AbstractElement
if ($fStyleIsObject) {
$styleWriter = new FontStyleWriter($fontStyle);
$style = $styleWriter->write();
} elseif (is_string($fontStyle)) {
$style = $fontStyle;
}
if ($style) {
$attribute = $fStyleIsObject ? 'style' : 'class';

View File

@ -52,12 +52,17 @@ class Font extends AbstractStyle
$css['background'] = $this->getValueIf($fgColor != '', $fgColor);
$css['font-weight'] = $this->getValueIf($style->isBold(), 'bold');
$css['font-style'] = $this->getValueIf($style->isItalic(), 'italic');
$css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'italic');
$css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'super');
$css['vertical-align'] = $this->getValueIf($style->isSubScript(), 'sub');
$css['vertical-align'] = '';
$css['vertical-align'] .= $this->getValueIf($style->isSuperScript(), 'super');
$css['vertical-align'] .= $this->getValueIf($style->isSubScript(), 'sub');
$css['text-decoration'] = '';
$css['text-decoration'] .= $this->getValueIf($underline, 'underline ');
$css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through ');
$css['text-transform'] = $this->getValueIf($style->isAllCaps(), 'uppercase');
$css['font-variant'] = $this->getValueIf($style->isSmallCaps(), 'small-caps');
$spacing = $style->getSpacing();
$css['letter-spacing'] = $this->getValueIf(!is_null($spacing), ($spacing / 20) . 'pt');
return $this->assembleCss($css);
}

View File

@ -80,6 +80,9 @@ class Paragraph extends AbstractStyle
$after = $spacing->getAfter();
$css['margin-top'] = $this->getValueIf(!is_null($before), ($before / 20) . 'pt');
$css['margin-bottom'] = $this->getValueIf(!is_null($after), ($after / 20) . 'pt');
} else {
$css['margin-top'] = '0';
$css['margin-bottom'] = '0';
}
return $this->assembleCss($css);