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
MathVariants
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 MathVariants sub-table from an OpenType MATH table.
9 *
10 * Spec: https://learn.microsoft.com/en-us/typography/opentype/spec/math#mathvariants-table
11 *
12 * Holds the data the painter uses to render stretchy delimiters
13 * (parentheses, brackets, integral signs, radical signs, arrows) at
14 * arbitrary heights / widths:
15 *
16 *   - A list of pre-drawn glyph variants at fixed sizes, sorted from
17 *     smallest to largest. The painter picks the smallest variant
18 *     whose advance exceeds the target.
19 *
20 *   - An optional glyph "assembly" that describes how to build a
21 *     delimiter at any size by stacking three or four glyph parts
22 *     (top + middle(s) + bottom for vertical; left + middle(s) +
23 *     right for horizontal).
24 *
25 * Vertical stretchy glyphs (parens, brackets) and horizontal
26 * stretchy glyphs (arrows, over/underbraces) are tracked in separate
27 * maps keyed by the base glyph ID.
28 */
29final readonly class MathVariants
30{
31    /**
32     * @param int $minConnectorOverlap Minimum overlap (in design
33     *        units) required between adjacent parts in a glyph
34     *        assembly.
35     * @param array<int, MathGlyphConstruction> $verticalConstructions
36     *        Base-glyph-ID → vertical construction. Used for tall
37     *        delimiters / radicals.
38     * @param array<int, MathGlyphConstruction> $horizontalConstructions
39     *        Base-glyph-ID → horizontal construction. Used for wide
40     *        arrows / over/under-braces.
41     */
42    public function __construct(
43        public int $minConnectorOverlap,
44        public array $verticalConstructions,
45        public array $horizontalConstructions,
46    ) {}
47}