From 4e8e69dc81466aa0ee7798e99c4768d95986b5f1 Mon Sep 17 00:00:00 2001
From: Georg Ehrke <developer@georgehrke.com>
Date: Mon, 28 Jul 2014 11:56:43 +0200
Subject: [PATCH] implement a txt preview fallback for the case that ttf is not
 support

---
 lib/private/preview/txt.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/private/preview/txt.php b/lib/private/preview/txt.php
index 063543c627..3059757fce 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;
-- 
GitLab