API / Minn\Theme / Typography

Typography final class

Minn\Theme\Typography · public/minn/src/Minn/Theme/Typography.php · 105 lines

Font sizes as the reference writes them (probe plugin-queue3): a size in px, rem or em, and, with fluid typography on, a clamp() that grows linearly from a minimum at a small viewport to the size (or the preset's own maximum) at the wide one.

Constants and properties

privateFLOOR = '14px'
privateSMALL_VIEWPORT = '320px'
privateWIDE_VIEWPORT = '1600px'

Public

staticvalueAndUnit(mixed $raw, array $options = array ( )): ?array#

A CSS length split into its number and unit (px, rem or em, or the units given), converted to another unit on request at a 16px root (or the one given); a bare number is px. Null for anything else.

$optionsarray{coerce_to?: string, root_size_value?: int|float, acceptable_units?: list<string>}
@return array{value: float, unit: string}|null
staticfontSize(array $preset, array $settings): mixed#

A font size preset as CSS (wp_get_typography_font_size_value). It stays as written unless fluid typography is on and the size is in a known unit and above the floor (14px, or the settings' minFontSize); then it grows from a minimum (the preset's own, else the size scaled by 1 - 0.075 log2 of its px, held between 0.25 and 0.75, never under the floor) to a maximum (the preset's own, else the size).

$presetarray<string, mixed>
$settingsarray<string, mixed>typography and layout, merged over the global settings
staticclamp(?string $minViewport, ?string $maxViewport, ?string $minSize, ?string $maxSize, int|float|null $scale): ?string#

The clamp() between two sizes over two viewport widths (wp_get_computed_fluid_typography_value): the slope in the minimum's unit, the base in rem. Null when a size or a width is missing or in an unknown unit, or the widths are equal.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatenumber(int|float $value): string#

A number as PHP writes a float: no trailing ".0".