Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CFFFontFile | |
83.33% |
5 / 6 |
|
50.00% |
1 / 2 |
3.04 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Font\FontFile; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfName; |
| 9 | use Phpdftk\Pdf\Core\PdfReference; |
| 10 | use Phpdftk\Pdf\Core\PdfStream; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | |
| 14 | /** |
| 15 | * CFF / Type 1C / CIDFontType0C font program stream — ISO 32000-2 §9.9, |
| 16 | * Table 124. Referenced from `FontDescriptor::$fontFile3`. The /Subtype |
| 17 | * entry distinguishes the flavor: |
| 18 | * |
| 19 | * /Type1C — bare CFF font program (Type 1 compatible) |
| 20 | * /CIDFontType0C — CFF font program for CID-keyed fonts |
| 21 | * /OpenType — OpenType font file (CFF or TTF outlines) |
| 22 | */ |
| 23 | #[RequiresPdfVersion(PdfVersion::V1_6)] |
| 24 | class CFFFontFile extends PdfStream |
| 25 | { |
| 26 | public PdfName $subtype; |
| 27 | public ?PdfReference $metadata = null; |
| 28 | |
| 29 | public function __construct(string $bytes, string $subtype = 'Type1C') |
| 30 | { |
| 31 | parent::__construct(new PdfDictionary(), $bytes); |
| 32 | $this->subtype = new PdfName($subtype); |
| 33 | } |
| 34 | |
| 35 | public function toPdf(): string |
| 36 | { |
| 37 | $this->dictionary->set('Subtype', $this->subtype); |
| 38 | if ($this->metadata !== null) { |
| 39 | $this->dictionary->set('Metadata', $this->metadata); |
| 40 | } |
| 41 | return parent::toPdf(); |
| 42 | } |
| 43 | } |