FontFaces final class
Minn\Theme\FontFaces · public/minn/src/Minn/Theme/FontFaces.php · 119 lines
fonts a theme.json declares in the shape they are printed from.
A face needs a family and at least one source it can name a format for. Its rule lists family (quoted unless it is one word or already carries quotes), style (normal), weight (400), display (fallback unless it is one the reference knows), the sources, then any other face property in the order given. Sources go data URIs first, then woff2, woff, truetype, embedded-opentype and opentype; anything else is dropped.
Constants and properties
| private | DISPLAYS = array ( 0 => 'auto', 1 => 'block', 2 => 'fallback', 3 => 'swap', 4 => 'optional', ) | |
| private | PROPERTIES = array ( 0 => 'ascent-override', 1 => 'descent-override', 2 => 'font-display', 3 => 'font-family', 4 => 'font-stretch', 5 => 'font-style', 6 => 'font-weight', 7 => 'font-variant', 8 => 'font-feature-settings', 9 => 'font-variation-settings', 10 => 'line-gap-override', 11 => 'size-adjust', 12 => 'src', 13 => 'unicode-range', ) | |
| private | FORMATS = array ( 'woff2' => 'woff2', 'woff' => 'woff', 'ttf' => 'truetype', 'eot' => 'embedded-opentype', 'otf' => 'opentype', ) |
Public
| static | css(array $fonts): string# | The rules for fonts given as families of faces, one rule a line; '' when no face can be printed.
| |||
| static | fromSettings(array $settings, Closure $fileUri): array# | The fonts a theme.json's settings declare, one list of faces per family that has any: each face's sources first (file:./ ones through $fileUri), then its family (the first name of its own, or of the family's, unquoted), then its other properties in kebab case.
@return list<list<array<string, mixed>>> |
Internals 5
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | rule(array $face): string# | One face's rule, or '' when it has no family or no source it can print. | |||
| private | sources(mixed $src): string# | The sources in the order the reference prints them: data URIs, then one each by format. | |||
| private | family(string $family): string# | A family name as printed: as given when it carries quotes or is one word, quoted otherwise. | |||
| private | variations(array $settings): string# | font-variation-settings given as axis => value, run together as the reference prints them. @param array<string, mixed> $settings
| |||
| private | firstName(string $family): string# | The first name in a comma-separated family list, without its quotes. |
Nothing matches.