From: Georg Ehrke Date: Mon, 28 Jul 2014 09:56:43 +0000 (+0200) Subject: implement a txt preview fallback for the case that ttf is not support X-Git-Tag: v8.0.0alpha1~948^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4e8e69dc81466aa0ee7798e99c4768d95986b5f1;p=nextcloud-server.git implement a txt preview fallback for the case that ttf is not support --- diff --git a/lib/private/preview/txt.php b/lib/private/preview/txt.php index 063543c6279..3059757fcec 100644 --- a/lib/private/preview/txt.php +++ b/lib/private/preview/txt.php @@ -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;