Commit 4e8e69dc authored by Georg Ehrke's avatar Georg Ehrke
Browse files

implement a txt preview fallback for the case that ttf is not support

parent 11214219
......@@ -44,13 +44,20 @@ class TXT extends Provider {
$fontFile .= '/../../../core';
$fontFile .= '/fonts/OpenSans-Regular.ttf';
$canUseTTF = function_exists('imagettftext');
foreach($lines as $index => $line) {
$index = $index + 1;
$x = (int) 1;
$y = (int) ($index * $lineSize);
imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontFile, $line);
if ($canUseTTF === true) {
imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontFile, $line);
} else {
$y -= $fontSize;
imagestring($image, 1, $x, $y, $line, $textColor);
}
if(($index * $lineSize) >= $maxY) {
break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment