summaryrefslogtreecommitdiffstats
path: root/lib/private/preview/txt.php
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2014-07-28 11:56:43 +0200
committerGeorg Ehrke <developer@georgehrke.com>2014-07-28 13:05:08 +0200
commit4e8e69dc81466aa0ee7798e99c4768d95986b5f1 (patch)
tree48114ad9506b12f13aa39c11781e7dd6d7b934bd /lib/private/preview/txt.php
parent11214219f3e7c4261af817dd2720766285830ec1 (diff)
downloadnextcloud-server-4e8e69dc81466aa0ee7798e99c4768d95986b5f1.tar.gz
nextcloud-server-4e8e69dc81466aa0ee7798e99c4768d95986b5f1.zip
implement a txt preview fallback for the case that ttf is not support
Diffstat (limited to 'lib/private/preview/txt.php')
-rw-r--r--lib/private/preview/txt.php9
1 files changed, 8 insertions, 1 deletions
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;