Refactor font family rendering using CSS inlining
We don't reset font family on any level, so there is no need to bubble the setting using a preprocessor and render the inline styles explicitly in every block. In this commit, I change how font-family settings are distributed/rendered in the email renderer. In the new approach, we rely on class names defining font-family and a generated CSS sheet with font-family definitions. We apply the font-family CSS by inlining CSS rules for families in the later phase of rendering after all individual blocks are processed. [MAILPOET-5740]
This commit is contained in:
committed by
Jan Lysý
parent
a7aaf97070
commit
e8bb1b5ac0
@ -236,4 +236,14 @@ class SettingsController {
|
||||
/** @var array $themeJson */
|
||||
return new \WP_Theme_JSON($themeJson);
|
||||
}
|
||||
|
||||
public function getStylesheetForRendering(): string {
|
||||
$settings = $this->getTheme()->get_settings();
|
||||
$css = '';
|
||||
// Font family classes
|
||||
foreach ($settings['typography']['fontFamilies']['theme'] as $fontFamily) {
|
||||
$css .= ".has-{$fontFamily['slug']}-font-family { font-family: {$fontFamily['fontFamily']}; } \n";
|
||||
}
|
||||
return $css;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user