#57065 closed enhancement (duplicate)
Fluid typography: custom values should be set as maximum font size, sizes below minimum shouldn't be clamped
Reported by: | ramonopoly | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1 |
Component: | Editor | Keywords: | |
Focuses: | css | Cc: |
Description
For 6.1.1
When converting custom font sizes to fluid values, the fluid typography functions calculate the minimum and maximum font sizes either size of the given custom font size.
Depending on the viewport width, the resulting fluid value may have a maximum font size value larger than the original custom value.
This may contradict user expectations.
All custom values should act as the maximum value in a clamp() function.
For example, if 8px is the custom value provided, it would be the maximum as would 1000px.
As for the minimum size, wherever the typography functions calculate one, that is, a min font size is not specified by theme.json, do not clampify font sizes <=14px. This is to prevent generating tiny font sizes.
See original Gutenberg issue in https://github.com/WordPress/gutenberg/issues/45504
Related trac ticket that introduced fluid typography in 6.1: https://core.trac.wordpress.org/ticket/56467
Change History (6)
This ticket was mentioned in PR #3602 on WordPress/wordpress-develop by @ramonopoly.
2 years ago
#1
- Keywords has-patch has-unit-tests added
@ramonopoly commented on PR #3602:
2 years ago
#2
Failing PHPUnit 7.1 tests look unrelated
Backporting changes in https://github.com/WordPress/gutenberg/pull/45536
Trac ticket: https://core.trac.wordpress.org/ticket/57065#ticket
### Updates to the fluid typography rules:
>16px
. This applies to custom values from the editor or single-value theme.json styles. Font sizes below this will not be clamped.fluid.min
value has been specified, the lower bound rule of>16px
won't be enforced on this value. Presets with a fluid object therefore, give precedence to theme author's values.fluid.max
but there isfluid.min
, use the incoming"size"
value as the max.fluid.min
but there is afluid.max
, usesize * min_size_factor
as the min. Here we do enforce the lower bound rule of>16px
, because Gutenberg is computing the min value. This is consistent with the way we calculate minimum sizes for single or custom values.### Testing
Using theme 2023
Add some text blocks to the editor, apply presets and custom sizes, and ensure they appear as they should in the editor and frontend at various viewport widths.
The size value should act at the upper bound of any clamp value.
Custom font sizes <=14px will not be clamped.
Please test by playing around with: