1<?php declare(strict_types=1); 2 3namespace PrinsFrank\PdfParser\Document\Font; 4 5readonly class FontWidths { 6 /** @param list<float> $widths */ 7 public function __construct( 8 public int $firstChar, 9 public array $widths, 10 ) {} 11 12 public function getWidthForCharacter(int $characterCode): ?float { 13 $width = $this->widths[$characterCode - $this->firstChar] ?? null; 14 if ($width === null) { 15 return null; 16 } 17 18 return $width / 1000; 19 } 20} 21