mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 19:20:35 -04:00
implement a txt preview fallback for the case that ttf is not support
This commit is contained in:
parent
11214219f3
commit
4e8e69dc81
1 changed files with 8 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue