@@ -682,10 +682,14 @@ protected static function parseStyle($attribute, $styles)
682
682
} else {
683
683
$ which = '' ;
684
684
}
685
- // normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
686
- $ size = strtolower (trim ($ matches [1 ]));
687
- // BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($size)
688
- $ size = ($ size == '1px ' ) ? 1 : Converter::cssToTwip ($ size );
685
+ // Note - border width normalization:
686
+ // Width of border in Word is calculated differently than HTML borders, usually showing up too bold.
687
+ // Smallest 1px (or 1pt) appears in Word like 2-3px/pt in HTML once converted to twips.
688
+ // Therefore we need to normalize converted twip value to cca 1/2 of value.
689
+ // This may be adjusted, if better ratio or formula found.
690
+ // BC change: up to ver. 0.17.0 was $size converted to points - Converter::cssToPoint($size)
691
+ $ size = Converter::cssToTwip ($ matches [1 ]);
692
+ $ size = intval ($ size / 2 );
689
693
// valid variants may be e.g. borderSize, borderTopSize, borderLeftColor, etc ..
690
694
$ styles ["border {$ which }Size " ] = $ size ; // twips
691
695
$ styles ["border {$ which }Color " ] = trim ($ matches [2 ], '# ' );
@@ -884,10 +888,10 @@ protected static function mapAlignVertical($alignment)
884
888
case 'baseline ' :
885
889
return 'top ' ;
886
890
default :
887
- // @discuss - which one should apply:
888
- // - Word uses default vert. alignment: top
889
- // - all browsers use default vert. alignment: middle
890
- // Returning empty string means attribute wont be set so use Word default (top).
891
+ // @discuss - which one should apply:
892
+ // - Word uses default vert. alignment: top
893
+ // - all browsers use default vert. alignment: middle
894
+ // Returning empty string means attribute wont be set so use Word default (top).
891
895
return '' ;
892
896
}
893
897
}
0 commit comments