Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| FontFeatureSettings | |
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.4 — typed `font-feature-settings` value. |
| 9 | * Comma-separated list of {@see FontFeatureValue} entries. The |
| 10 | * shaper consumes the list to enable/disable individual OpenType |
| 11 | * GSUB / GPOS feature tags. |
| 12 | * |
| 13 | * font-feature-settings: "tnum", "liga" off, "ss01" 1; |
| 14 | */ |
| 15 | final readonly class FontFeatureSettings extends Value |
| 16 | { |
| 17 | /** |
| 18 | * @param list<FontFeatureValue> $features |
| 19 | */ |
| 20 | public function __construct(public array $features) {} |
| 21 | |
| 22 | public function toCss(): string |
| 23 | { |
| 24 | if ($this->features === []) { |
| 25 | return 'normal'; |
| 26 | } |
| 27 | return implode(', ', array_map( |
| 28 | static fn(FontFeatureValue $f): string => $f->toCss(), |
| 29 | $this->features, |
| 30 | )); |
| 31 | } |
| 32 | } |