Skip to content

Commit 376e6b3

Browse files
committed
Emulation: don't crash when all text is one line
1 parent d4ff472 commit 376e6b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Emulation/Canvas.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ private function splitText(\ImagickDraw $canvas, string $text): array
109109
{
110110
$words = \preg_split('~\s~u', \trim($text), -1, \PREG_SPLIT_NO_EMPTY);
111111

112+
if (empty($words)) {
113+
return [
114+
$this->image->queryFontMetrics($canvas, $text)['textWidth'],
115+
[$text],
116+
];
117+
}
118+
112119
$i = 1;
113120
$lines = [];
114121
$lineWidth = [];

0 commit comments

Comments
 (0)