Fix 1px line rendering bug in Outlook 2016

[MAILPOET-3448]
This commit is contained in:
Pavel Dohnal
2021-05-25 12:12:01 +02:00
committed by Veljko V
parent 95fc533649
commit df7b961768
2 changed files with 33 additions and 0 deletions

View File

@ -16,6 +16,8 @@ class StylesHelper {
'borderColor' => 'border-color',
'borderRadius' => 'border-radius',
'lineHeight' => 'line-height',
'msoLineHeightAlt' => 'mso-line-height-alt',
'msoFontSize' => 'mso-ansi-font-size',
];
public static $font = [
'Arial' => "Arial, 'Helvetica Neue', Helvetica, sans-serif",
@ -147,7 +149,18 @@ class StylesHelper {
if (!preg_match('/mailpoet_paragraph|h[1-4]/i', $selector)) return $style;
$lineHeight = isset($style['lineHeight']) ? (float)$style['lineHeight'] : self::$defaultLineHeight;
$fontSize = (int)$style['fontSize'];
$msoLineHeight = round($lineHeight * $fontSize);
if ($msoLineHeight % 2 === 1) {
$msoLineHeight++;
}
$msoFontSize = $fontSize;
if ($msoFontSize % 2 === 1) {
$msoFontSize++;
}
$style['msoLineHeightAlt'] = sprintf('%spx', $msoLineHeight);
$style = ['msoFontSize' => sprintf('%spx', $msoFontSize)] + $style;
$style['lineHeight'] = sprintf('%spx', $lineHeight * $fontSize);
return $style;
}