Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
OpenTypeData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\FontParser;
6
7/**
8 * Parsed OpenType CFF font data — metrics, glyph widths, and raw CFF bytes.
9 *
10 * Mirrors TrueTypeData but adds the CFF table bytes and stores the
11 * full raw font file for potential whole-file embedding.
12 */
13readonly class OpenTypeData
14{
15    /**
16     * @param string $postScriptName  PostScript name (name table ID 6)
17     * @param string $familyName      Family name (name table ID 1)
18     * @param int    $ascent          Typographic ascender (1000 units/em)
19     * @param int    $descent         Typographic descender (negative, 1000 units/em)
20     * @param int    $capHeight       Cap height (1000 units/em)
21     * @param int    $xHeight         x-height (1000 units/em)
22     * @param float  $italicAngle     Italic angle in degrees
23     * @param int    $stemV           Estimated vertical stem width
24     * @param int    $flags           PDF font flags bitmask
25     * @param array<int, int>  $fontBBox        [xMin, yMin, xMax, yMax] (1000 units/em)
26     * @param array<int, int>  $charWidths      WinAnsi byte (32-255) → width (1000 units/em)
27     * @param array<int, int>  $unicodeMap      WinAnsi byte (32-255) → Unicode codepoint
28     * @param string $cffBytes        Raw CFF table bytes (for /FontFile3 /Subtype /CIDFontType0C)
29     * @param string $fontBytes       Raw OTF file bytes (for /FontFile3 /Subtype /OpenType)
30     * @param bool   $embeddingAllowed fsType restriction check
31     * @param int    $unitsPerEm      Font design units per em
32     * @param array<int, int>  $fullUnicodeToGid All Unicode → GID mappings
33     * @param array<int, int>  $glyphWidths     GID → advance width (design units)
34     * @param ?array<int, array<int, int>> $kernPairs leftGid => [rightGid => xAdvanceAdjust] (design units)
35     * @param ?array<int, list<array{components: int[], ligature: int}>> $ligatures firstGid => ligature rules
36     * @param ?array<int, int> $verticalWidths GID => vertical advance width (design units)
37     * @param ?int $underlinePosition `post` table FWord — offset of the underline's top edge from
38     *        the baseline (design units; negative = below baseline). Null if the table is missing.
39     * @param ?int $underlineThickness `post` table FWord — underline stroke thickness in design units.
40     */
41    public function __construct(
42        public string $postScriptName,
43        public string $familyName,
44        public int $ascent,
45        public int $descent,
46        public int $capHeight,
47        public int $xHeight,
48        public float $italicAngle,
49        public int $stemV,
50        public int $flags,
51        public array $fontBBox,
52        public array $charWidths,
53        public array $unicodeMap,
54        public string $cffBytes,
55        public string $fontBytes,
56        public bool $embeddingAllowed,
57        public int $unitsPerEm = 1000,
58        public array $fullUnicodeToGid = [],
59        public array $glyphWidths = [],
60        public ?array $kernPairs = null,
61        public ?array $ligatures = null,
62        public ?array $verticalWidths = null,
63        public ?int $underlinePosition = null,
64        public ?int $underlineThickness = null,
65    ) {}
66}