Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| FontVariationSettings | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
3.03 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toCss | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
2.02 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Value; |
| 6 | |
| 7 | /** |
| 8 | * CSS Fonts 4 §6.5 — typed `font-variation-settings` value. |
| 9 | * Comma-separated list of {@see FontVariationValue} entries. |
| 10 | * The shaper passes these to variable-font fvar lookups to pick |
| 11 | * the right glyph variant per axis. |
| 12 | * |
| 13 | * font-variation-settings: "wght" 600, "wdth" 95.5; |
| 14 | */ |
| 15 | final readonly class FontVariationSettings extends Value |
| 16 | { |
| 17 | /** |
| 18 | * @param list<FontVariationValue> $axes |
| 19 | */ |
| 20 | public function __construct(public array $axes) {} |
| 21 | |
| 22 | public function toCss(): string |
| 23 | { |
| 24 | if ($this->axes === []) { |
| 25 | return 'normal'; |
| 26 | } |
| 27 | return implode(', ', array_map( |
| 28 | static fn(FontVariationValue $v): string => $v->toCss(), |
| 29 | $this->axes, |
| 30 | )); |
| 31 | } |
| 32 | } |