15, 'tablet' => 15, 'mobile' => 15 ]; $fontStyle = $fontStyle ?? 'normal'; $textTransform = $textTransform ?? 'none'; $textDecoration = $textDecoration ?? 'auto'; $lineHeight = $lineHeight ?? '135%'; $letterSpace = $letterSpace ?? '0px'; $isEmptyFamily = !$isFamily || !$fontFamily || 'Default' === $fontFamily; $desktopFontSize = $fontSize['desktop'] ?? $fontSize; $tabletFontSize = $fontSize['tablet'] ?? $desktopFontSize; $mobileFontSize = $fontSize['mobile'] ?? $tabletFontSize; $styles = ( $isEmptyFamily ? '' : "font-family: '$fontFamily', $fontCategory;" ) . self::generateCss( $fontWeight, 'font-weight' ) . 'font-size: '. $desktopFontSize .'px;' . self::generateCss( $fontStyle, 'font-style' ) . self::generateCss( $textTransform, 'text-transform' ) . self::generateCss( $textDecoration, 'text-decoration' ) . self::generateCss( $lineHeight, 'line-height' ) . self::generateCss( $letterSpace, 'letter-spacing' ); // Google font link $linkQuery = ( !$fontVariant || 400 === $fontVariant ) ? '' : ( '400i' === $fontVariant ? ':ital@1' : ( false !== strpos( $fontVariant, '00i' ) ? ': ital, wght@1, '. str_replace( '00i', '00', $fontVariant ) .' ' : ": wght@$fontVariant " ) ); $link = $isEmptyFamily ? '' : 'https://fonts.googleapis.com/css2?family='. str_replace( ' ', '+', $fontFamily ) ."$linkQuery&display=swap"; return [ 'googleFontLink' => !$isUploadFont || $isEmptyFamily ? '' : "@import url( $link );", 'styles' => preg_replace( '/\s+/', ' ', trim( " $selector{ $styles } @media (max-width: 768px) { $selector{ font-size: $tabletFontSize" . "px; } } @media (max-width: 576px) { $selector{ font-size: $mobileFontSize" . "px; } } " ) ) ]; } }