parse fixed line space

This commit is contained in:
troosan 2018-03-19 22:43:10 +01:00
parent 97d60dd985
commit de01e86d41
1 changed files with 12 additions and 10 deletions

View File

@ -521,7 +521,18 @@ class Html
$styles['bgColor'] = trim($cValue, '#');
break;
case 'line-height':
$styles['lineHeight'] = Html::toMultiplier($cValue);
if (preg_match('/([0-9]+[a-z]+)/', $cValue, $matches)) {
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT;
$spacing = Converter::cssToTwip($matches[1]) / \PhpOffice\PhpWord\Style\Paragraph::LINE_HEIGHT;
} elseif (preg_match('/([0-9]+)%/', $cValue, $matches)) {
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
$spacing = ((int) $matches[1]) / 100;
} else {
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
$spacing = $cValue;
}
$styles['spacingLineRule'] = $spacingLineRule;
$styles['lineHeight'] = $spacing;
break;
case 'text-indent':
$styles['indentation']['firstLine'] = Converter::cssToTwip($cValue);
@ -681,15 +692,6 @@ class Html
return null;
}
private static function toMultiplier($cssValue)
{
if (preg_match('/([0-9]+)%/', $cssValue, $matches)) {
return ((int) $matches[1]) / 100;
}
return $cssValue;
}
/**
* Parse line break
*