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
ShapedGlyph
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\Text;
6
7/**
8 * One positioned glyph in a {@see ShapedRun}.
9 *
10 * `glyphId` is the font's internal index; `sourceOffset` / `sourceLength`
11 * point back into the original UTF-8 string so callers can round-trip
12 * between glyphs and source characters (needed for selection, hit testing,
13 * and copy-paste extraction).
14 *
15 * `advanceX` / `advanceY` are the glyph's contribution to the line's
16 * advance after kerning is applied; offsets are positional tweaks from
17 * GPOS mark / attachment data (zero for the simple shaper).
18 *
19 * All distances are in PDF user-space units (1pt = 1/72in) — i.e. already
20 * scaled by `fontSizePt / unitsPerEm`. Layout consumes them directly without
21 * needing the original font metrics.
22 */
23final readonly class ShapedGlyph
24{
25    public function __construct(
26        public int $glyphId,
27        public int $sourceOffset,
28        public int $sourceLength,
29        public float $advanceX,
30        public float $advanceY = 0.0,
31        public float $offsetX = 0.0,
32        public float $offsetY = 0.0,
33    ) {}
34}