File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -521,7 +521,18 @@ private static function parseStyle($attribute, $styles)
521
521
$ styles ['bgColor ' ] = trim ($ cValue , '# ' );
522
522
break ;
523
523
case 'line-height ' :
524
- $ styles ['lineHeight ' ] = Html::toMultiplier ($ cValue );
524
+ if (preg_match ('/([0-9]+[a-z]+)/ ' , $ cValue , $ matches )) {
525
+ $ spacingLineRule = \PhpOffice \PhpWord \SimpleType \LineSpacingRule::EXACT ;
526
+ $ spacing = Converter::cssToTwip ($ matches [1 ]) / \PhpOffice \PhpWord \Style \Paragraph::LINE_HEIGHT ;
527
+ } elseif (preg_match ('/([0-9]+)%/ ' , $ cValue , $ matches )) {
528
+ $ spacingLineRule = \PhpOffice \PhpWord \SimpleType \LineSpacingRule::AUTO ;
529
+ $ spacing = ((int ) $ matches [1 ]) / 100 ;
530
+ } else {
531
+ $ spacingLineRule = \PhpOffice \PhpWord \SimpleType \LineSpacingRule::AUTO ;
532
+ $ spacing = $ cValue ;
533
+ }
534
+ $ styles ['spacingLineRule ' ] = $ spacingLineRule ;
535
+ $ styles ['lineHeight ' ] = $ spacing ;
525
536
break ;
526
537
case 'text-indent ' :
527
538
$ styles ['indentation ' ]['firstLine ' ] = Converter::cssToTwip ($ cValue );
@@ -681,15 +692,6 @@ private static function mapAlign($cssAlignment)
681
692
return null ;
682
693
}
683
694
684
- private static function toMultiplier ($ cssValue )
685
- {
686
- if (preg_match ('/([0-9]+)%/ ' , $ cssValue , $ matches )) {
687
- return ((int ) $ matches [1 ]) / 100 ;
688
- }
689
-
690
- return $ cssValue ;
691
- }
692
-
693
695
/**
694
696
* Parse line break
695
697
*
You can’t perform that action at this time.
0 commit comments