Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| MathGlyphInfo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\FontParser; |
| 6 | |
| 7 | /** |
| 8 | * Parsed MathGlyphInfo sub-table from an OpenType MATH table. |
| 9 | * |
| 10 | * Spec: https://learn.microsoft.com/en-us/typography/opentype/spec/math#mathglyphinfo-table |
| 11 | * |
| 12 | * Holds per-glyph data the painter consults at layout time: |
| 13 | * |
| 14 | * - Italic-correction values: extra horizontal space to add after |
| 15 | * an italic-shaped glyph that an upright follower (subscripts, |
| 16 | * superscripts to the right of a slanted base) should bridge. |
| 17 | * |
| 18 | * - Top-accent attachment offsets: where a top accent |
| 19 | * (`<mover>` over an `<mi>x</mi>`) should attach horizontally. |
| 20 | * |
| 21 | * - Extended-shape coverage: glyph IDs that should be drawn with |
| 22 | * script-script vertical metrics even at script level (used by |
| 23 | * spec for very large operators / radical signs). |
| 24 | * |
| 25 | * - Math kern info: per-glyph corner kerning at the four sub/sup |
| 26 | * attachment points. Carried as raw bytes pending a dedicated |
| 27 | * parser in a follow-up slice - the structure is per-glyph |
| 28 | * CorrectionHeight + KernValue arrays at each corner. |
| 29 | * |
| 30 | * Each map's keys are glyph IDs (GIDs), values are FUnit shifts. |
| 31 | */ |
| 32 | final readonly class MathGlyphInfo |
| 33 | { |
| 34 | /** |
| 35 | * @param array<int, int> $italicCorrections gid → FUnit italic correction. |
| 36 | * @param array<int, int> $topAccentAttachments gid → FUnit top-accent attachment offset. |
| 37 | * @param array<int, true> $extendedShapes gid set (only keys matter). |
| 38 | * @param string $kernInfoBytes Raw MathKernInfo sub-table bytes (parsed later). |
| 39 | */ |
| 40 | public function __construct( |
| 41 | public array $italicCorrections, |
| 42 | public array $topAccentAttachments, |
| 43 | public array $extendedShapes, |
| 44 | public string $kernInfoBytes, |
| 45 | ) {} |
| 46 | } |