Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CFFFontFile
83.33% covered (warning)
83.33%
5 / 6
50.00% covered (danger)
50.00%
1 / 2
3.04
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Font\FontFile;
6
7use Phpdftk\Pdf\Core\PdfDictionary;
8use Phpdftk\Pdf\Core\PdfName;
9use Phpdftk\Pdf\Core\PdfReference;
10use Phpdftk\Pdf\Core\PdfStream;
11use Phpdftk\Pdf\Core\PdfVersion;
12use 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)]
24class 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}