<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[54646] trunk: Editor: Add font size constraints for fluid typography.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/54646">54646</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/54646","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-10-19 12:25:21 +0000 (Wed, 19 Oct 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Add font size constraints for fluid typography.
This commit:
* Adds default minimum font size limits so that min font size, where provided, does not become smaller than `14px`/`0.875rem`/`0.875em`.
* For font sizes of `< 14px` that have no defined minimum sizes, uses the font size to set the floor of the `clamp()` value.
This bugfix prevents converting existing small font sizes to clamp values that will reduce their font size even further in narrow widths. It therefore improves backward compatibility and accessibility.
Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/44993 <a href="https://core.trac.wordpress.org/ticket/44993">#44993</a> Fluid typography: add font size constraints]
Follow-up to <a href="https://core.trac.wordpress.org/changeset/54260">[54260]</a>, <a href="https://core.trac.wordpress.org/changeset/54360">[54360]</a>, <a href="https://core.trac.wordpress.org/changeset/54497">[54497]</a>, <a href="https://core.trac.wordpress.org/changeset/54500">[54500]</a>.
Props ramonopoly, andrewserong, isabel_brison, Joen, bernhard-reiter.
See <a href="https://core.trac.wordpress.org/ticket/56467">#56467</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportstypographyphp">trunk/src/wp-includes/block-supports/typography.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportstypographyphp">trunk/tests/phpunit/tests/block-supports/typography.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblocksupportstypographyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/typography.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/typography.php 2022-10-19 11:42:24 UTC (rev 54645)
+++ trunk/src/wp-includes/block-supports/typography.php 2022-10-19 12:25:21 UTC (rev 54646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,11 +119,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] )
</span><span class="cx" style="display: block; padding: 0 10px"> ? $block_attributes['style']['typography']['fontSize']
</span><span class="cx" style="display: block; padding: 0 10px"> : null;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $typography_block_styles['fontSize'] = $preset_font_size ? $preset_font_size : wp_get_typography_font_size_value(
- array(
- 'size' => $custom_font_size,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $typography_block_styles['fontSize'] = $preset_font_size ? $preset_font_size : wp_get_typography_font_size_value(
+ array(
+ 'size' => $custom_font_size,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $has_font_family_support && ! $should_skip_font_family ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -348,8 +348,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $unit = $options['coerce_to'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * No calculation is required if swapping between em and rem yet,
+ * since we assume a root size value. Later we might like to differentiate between
+ * :root font size (rem) and parent element font size (em) relativity.
+ */
+ if ( ( 'em' === $options['coerce_to'] || 'rem' === $options['coerce_to'] ) && ( 'em' === $unit || 'rem' === $unit ) ) {
+ $unit = $options['coerce_to'];
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $value,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => round( $value, 3 ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'unit' => $unit,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,13 +389,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null;
</span><span class="cx" style="display: block; padding: 0 10px"> $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Grab the minimum font size and normalize it in order to use the value for calculations.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Normalizes the minimum font size in order to use the value for calculations.
</ins><span class="cx" style="display: block; padding: 0 10px"> $minimum_font_size = wp_get_typography_value_and_unit( $minimum_font_size_raw );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We get a 'preferred' unit to keep units consistent when calculating, otherwise the result will not be accurate.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * We get a 'preferred' unit to keep units consistent when calculating,
+ * otherwise the result will not be accurate.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Grab the maximum font size and normalize it in order to use the value for calculations.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Normalizes the maximum font size in order to use the value for calculations.
</ins><span class="cx" style="display: block; padding: 0 10px"> $maximum_font_size = wp_get_typography_value_and_unit(
</span><span class="cx" style="display: block; padding: 0 10px"> $maximum_font_size_raw,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -394,12 +406,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Protect against unsupported units.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Checks for mandatory min and max sizes, and protects against unsupported units.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $maximum_font_size || ! $minimum_font_size ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return null;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Use rem for accessible fluid target font scaling.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Uses rem for accessible fluid target font scaling.
</ins><span class="cx" style="display: block; padding: 0 10px"> $minimum_font_size_rem = wp_get_typography_value_and_unit(
</span><span class="cx" style="display: block; padding: 0 10px"> $minimum_font_size_raw,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,8 +439,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit;
</span><span class="cx" style="display: block; padding: 0 10px"> $linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $maximum_viewport_width['value'] - $minimum_viewport_width['value'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $linear_factor = round( $linear_factor, 3 ) * $scale_factor;
- $fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $linear_factor_scaled = round( $linear_factor * $scale_factor, 3 );
+ $linear_factor_scaled = empty( $linear_factor_scaled ) ? 1 : $linear_factor_scaled;
+ $fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor_scaled)";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return "clamp($minimum_font_size_raw, $fluid_target_font_size, $maximum_font_size_raw)";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -478,6 +491,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $default_minimum_font_size_factor = 0.75;
</span><span class="cx" style="display: block; padding: 0 10px"> $default_maximum_font_size_factor = 1.5;
</span><span class="cx" style="display: block; padding: 0 10px"> $default_scale_factor = 1;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $default_minimum_font_size_limit = '14px';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Font sizes.
</span><span class="cx" style="display: block; padding: 0 10px"> $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -499,13 +513,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $preset['size'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If no fluid min or max font sizes are available, create some using min/max font size factors.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If no fluid max font size is available, create one using max font size factor.
+ if ( ! $maximum_font_size_raw ) {
+ $maximum_font_size_raw = round( $preferred_size['value'] * $default_maximum_font_size_factor, 3 ) . $preferred_size['unit'];
+ }
+
+ // If no fluid min font size is available, create one using min font size factor.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $minimum_font_size_raw ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $minimum_font_size_raw = ( $preferred_size['value'] * $default_minimum_font_size_factor ) . $preferred_size['unit'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $minimum_font_size_raw = round( $preferred_size['value'] * $default_minimum_font_size_factor, 3 ) . $preferred_size['unit'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $maximum_font_size_raw ) {
- $maximum_font_size_raw = ( $preferred_size['value'] * $default_maximum_font_size_factor ) . $preferred_size['unit'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Normalizes the minimum font size limit according to the incoming unit, so we can perform checks using it.
+ $minimum_font_size_limit = wp_get_typography_value_and_unit(
+ $default_minimum_font_size_limit,
+ array(
+ 'coerce_to' => $preferred_size['unit'],
+ )
+ );
+
+ if ( ! empty( $minimum_font_size_limit ) ) {
+ /*
+ * If a minimum size was not passed to this function
+ * and the user-defined font size is lower than $minimum_font_size_limit,
+ * then use the user-defined font size as the minimum font-size.
+ */
+ if ( ! isset( $fluid_font_size_settings['min'] ) && $preferred_size['value'] < $minimum_font_size_limit['value'] ) {
+ $minimum_font_size_raw = implode( '', $preferred_size );
+ } else {
+ $minimum_font_size_parsed = wp_get_typography_value_and_unit(
+ $minimum_font_size_raw,
+ array(
+ 'coerce_to' => $preferred_size['unit'],
+ )
+ );
+
+ /*
+ * If the passed or calculated minimum font size is lower than $minimum_font_size_limit
+ * use $minimum_font_size_limit instead.
+ */
+ if ( ! empty( $minimum_font_size_parsed ) && $minimum_font_size_parsed['value'] < $minimum_font_size_limit['value'] ) {
+ $minimum_font_size_raw = implode( '', $minimum_font_size_limit );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fluid_font_size_value = wp_get_computed_fluid_typography_value(
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportstypographyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/block-supports/typography.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/typography.php 2022-10-19 11:42:24 UTC (rev 54645)
+++ trunk/tests/phpunit/tests/block-supports/typography.php 2022-10-19 12:25:21 UTC (rev 54646)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,11 +363,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_return_value_when_value_is_already_clamped' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'font_size_preset' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => 'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'fluid' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_return_value_with_unsupported_unit' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -384,7 +384,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'size' => '1.75rem',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(1.3125rem, 1.3125rem + ((1vw - 0.48rem) * 2.524), 2.625rem)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(1.313rem, 1.313rem + ((1vw - 0.48rem) * 2.523), 2.625rem)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_fluid_value_with_floats_with_units' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -392,7 +392,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'size' => '100.175px',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(75.13125px, 4.695703125rem + ((1vw - 7.68px) * 9.03), 150.2625px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(75.131px, 4.696rem + ((1vw - 7.68px) * 9.03), 150.263px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_fluid_value_with_integer_coerced_to_px' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -400,7 +400,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'size' => 33,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(24.75px, 1.546875rem + ((1vw - 7.68px) * 2.975), 49.5px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(24.75px, 1.547rem + ((1vw - 7.68px) * 2.975), 49.5px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_fluid_value_with_float_coerced_to_px' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -408,7 +408,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'size' => 100.23,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(75.1725px, 4.69828125rem + ((1vw - 7.68px) * 9.035), 150.345px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(75.173px, 4.698rem + ((1vw - 7.68px) * 9.035), 150.345px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_default_fluid_values_with_empty_fluid_array' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,7 +417,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'fluid' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_default_fluid_values_with_null_value' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -426,9 +426,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'fluid' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 2.524), 42px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'return_clamped_value_if_min_font_size_is_greater_than_max' => array(
+ 'font_size_preset' => array(
+ 'size' => '3rem',
+ 'fluid' => array(
+ 'min' => '5rem',
+ 'max' => '32px',
+ ),
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(5rem, 5rem + ((1vw - 0.48rem) * -5.769), 32px)',
+ ),
+
</ins><span class="cx" style="display: block; padding: 0 10px"> 'return_size_with_invalid_fluid_units' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'font_size_preset' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'size' => '10em',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -441,8 +453,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'expected_output' => '10em',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'return_fluid_clamp_value' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'return_clamped_size_where_no_min_is_given_and_less_than_default_min_size' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'font_size_preset' => array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => '3px',
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(3px, 0.188rem + ((1vw - 7.68px) * 0.18), 4.5px)',
+ ),
+
+ 'return_fluid_clamp_value_with_different_min_max_units' => array(
+ 'font_size_preset' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'size' => '28px',
</span><span class="cx" style="display: block; padding: 0 10px"> 'fluid' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'min' => '20px',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,8 +492,78 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'clamp(21px, 1.3125rem + ((1vw - 7.68px) * 7.091), 80px)',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 7.091), 80px)',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ 'should_adjust_computed_min_in_px_to_min_limit' => array(
+ 'font_size_preset' => array(
+ 'size' => '14px',
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.841), 21px)',
+ ),
+
+ 'should_adjust_computed_min_in_rem_to_min_limit' => array(
+ 'font_size_preset' => array(
+ 'size' => '1.1rem',
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 1.49), 1.65rem)',
+ ),
+
+ 'default_return_clamp_value_with_replaced_fluid_min_value_in_em' => array(
+ 'font_size_preset' => array(
+ 'size' => '1.1em',
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(0.875em, 0.875rem + ((1vw - 0.48em) * 1.49), 1.65em)',
+ ),
+
+ 'should_adjust_fluid_min_value_in_px_to_min_limit' => array(
+ 'font_size_preset' => array(
+ 'size' => '20px',
+ 'fluid' => array(
+ 'min' => '12px',
+ ),
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(14px, 0.875rem + ((1vw - 7.68px) * 1.923), 30px)',
+ ),
+
+ 'should_adjust_fluid_min_value_in_rem_to_min_limit' => array(
+ 'font_size_preset' => array(
+ 'size' => '1.5rem',
+ 'fluid' => array(
+ 'min' => '0.5rem',
+ ),
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 2.644), 2.25rem)',
+ ),
+
+ 'should_adjust_fluid_min_value_but_honor_max_value' => array(
+ 'font_size_preset' => array(
+ 'size' => '1.5rem',
+ 'fluid' => array(
+ 'min' => '0.5rem',
+ 'max' => '5rem',
+ ),
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 7.933), 5rem)',
+ ),
+
+ 'should_return_fluid_value_when_min_and_max_font_sizes_are_equal' => array(
+ 'font_size_preset' => array(
+ 'size' => '4rem',
+ 'fluid' => array(
+ 'min' => '30px',
+ 'max' => '30px',
+ ),
+ ),
+ 'should_use_fluid_typography' => true,
+ 'expected_output' => 'clamp(30px, 1.875rem + ((1vw - 7.68px) * 1), 30px)',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -547,7 +637,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_value_with_fluid_typography' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'font_size_value' => '50px',
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => 'font-size:clamp(37.5px, 2.34375rem + ((1vw - 7.68px) * 4.507), 75px);',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => 'font-size:clamp(37.5px, 2.344rem + ((1vw - 7.68px) * 4.507), 75px);',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -623,13 +713,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'block_content' => '<p class="has-medium-font-size" style=" font-size: 20px ; ">A paragraph inside a group</p>',
</span><span class="cx" style="display: block; padding: 0 10px"> 'font_size_value' => '20px',
</span><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => '<p class="has-medium-font-size" style=" font-size:clamp(15px, 0.9375rem + ((1vw - 7.68px) * 1.803), 30px); ">A paragraph inside a group</p>',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => '<p class="has-medium-font-size" style=" font-size:clamp(15px, 0.938rem + ((1vw - 7.68px) * 1.803), 30px); ">A paragraph inside a group</p>',
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'return_content_with_first_match_replace_only' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'block_content' => "<div class=\"wp-block-group\" style=\"font-size:1em\"> \n \n<p style=\"font-size:1em\">A paragraph inside a group</p></div>",
- 'font_size_value' => '1em',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'block_content' => "<div class=\"wp-block-group\" style=\"font-size:1.5em\"> \n \n<p style=\"font-size:1.5em\">A paragraph inside a group</p></div>",
+ 'font_size_value' => '1.5em',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'should_use_fluid_typography' => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'expected_output' => "<div class=\"wp-block-group\" style=\"font-size:clamp(0.75em, 0.75em + ((1vw - 0.48em) * 1.442), 1.5em);\"> \n \n<p style=\"font-size:1em\">A paragraph inside a group</p></div>",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'expected_output' => "<div class=\"wp-block-group\" style=\"font-size:clamp(1.125em, 1.125rem + ((1vw - 0.48em) * 2.163), 2.25em);\"> \n \n<p style=\"font-size:1.5em\">A paragraph inside a group</p></div>",
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>