Skip to content

Commit

Permalink
fixed warnings in Font.php
Browse files Browse the repository at this point in the history
Warnings were:

1) /var/www/html/src/Smalot/PdfParser/Font.php:292
range(): Argument #1 ($start) must not be empty, casted to 0

Triggered by:

* PHPUnitTests\Integration\FontTest::testCalculateTextWidthNoWidthsKey
  /var/www/html/tests/PHPUnit/Integration/FontTest.php:473

2) /var/www/html/src/Smalot/PdfParser/Font.php:292
range(): Argument #2 ($end) must not be empty, casted to 0

Triggered by:

* PHPUnitTests\Integration\FontTest::testCalculateTextWidthNoWidthsKey
  /var/www/html/tests/PHPUnit/Integration/FontTest.php:473
  • Loading branch information
k00ni committed Sep 26, 2024
1 parent 21f7d8b commit 8cebc93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Smalot/PdfParser/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ public function calculateTextWidth(string $text, ?array &$missing = null): ?floa
$widths = $details['Widths'] ?? [];

// Widths array is zero indexed but table is not. We must map them based on FirstChar and LastChar
$width_map = array_flip(range($details['FirstChar'], $details['LastChar']));
// note: in some cases the values for FirstChar or LastChar are null here
$width_map = array_flip(range((int) $details['FirstChar'], (int) $details['LastChar']));

$width = null;
$missing = [];
Expand Down

0 comments on commit 8cebc93

Please sign in to comment.