Automattic\WooCommerce\EmailEditor\Engine
Site_Style_Sync_Controller::convert_typography_styles
Convert site typography styles to email format
Method of the class: Site_Style_Sync_Controller{}
No Hooks.
Returns
Array. Email-compatible typography styles.
Usage
// private - for code of main (parent) class only $result = $this->convert_typography_styles( $typography_styles, $element ): array;
- $typography_styles(array) (required)
- Site typography styles.
- $element(string)
- Optional element name for context-aware fallbacks.
Default:''
Site_Style_Sync_Controller::convert_typography_styles() Site Style Sync Controller::convert typography styles code WC 10.7.0
private function convert_typography_styles( array $typography_styles, string $element = '' ): array {
$email_typography = array();
// Handle special cases with processors.
$this->resolve_and_assign( $typography_styles, 'fontFamily', $email_typography, array( $this, 'convert_to_email_safe_font' ) );
$this->resolve_and_assign(
$typography_styles,
'fontSize',
$email_typography,
function ( $value ) use ( $element ) {
// Try element-specific fallback first, then global fallback.
$fallback = null;
if ( $element ) {
$fallback = $this->get_base_theme_value( array( 'styles', 'elements', $element, 'typography', 'fontSize' ) );
}
if ( ! $fallback ) {
$fallback = $this->get_base_theme_value( array( 'styles', 'typography', 'fontSize' ) );
}
return $this->convert_to_px_size( $value, $fallback );
}
);
// Handle compatible properties without processing.
$compatible_props = array( 'fontWeight', 'fontStyle', 'lineHeight', 'letterSpacing', 'textTransform', 'textDecoration' );
foreach ( $compatible_props as $prop ) {
$this->resolve_and_assign( $typography_styles, $prop, $email_typography );
}
return $email_typography;
}