Skip to content

Commit 0eeb6b2

Browse files
committed
Fix toUnicodeCMap parsing with multiple targetValues
1 parent 4463727 commit 0eeb6b2

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/Document/CMap/ToUnicode/ToUnicodeCMapParser.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ public static function parse(Stream $stream, int $startOffset, int $nrOfBytes):
6969
}
7070

7171
foreach ($matchesBFRange as $matchBFRange) {
72+
$targetString = trim($matchBFRange['targetString']);
73+
if (str_starts_with($targetString, '[') && str_ends_with($targetString, ']')) {
74+
preg_match_all('/<([^>]+)>/', $targetString, $hexMatches);
75+
$targetValues = $hexMatches[1];
76+
} else {
77+
$targetValues = [trim($targetString, '<>')];
78+
}
79+
7280
$bfCharRangeInfo[$beginBFRangePos][] = new BFRange(
7381
(int) hexdec(trim($matchBFRange['start'])),
7482
(int) hexdec(trim($matchBFRange['end'])),
75-
array_map(
76-
fn(string $value) => trim($value),
77-
explode('><', rtrim(ltrim(str_replace(' ', '', $matchBFRange['targetString']), '[<'), '>]')),
78-
),
83+
$targetValues,
7984
);
8085
}
8186
$lastPos = $endBFRangePos;

0 commit comments

Comments
 (0)