38 lines
1001 B
PHP
38 lines
1001 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
$fontDir = __DIR__ . '/../fonts';
|
|
$roboto = $fontDir . '/Roboto-Bold.ttf';
|
|
$lora = $fontDir . '/Lora-Bold.ttf';
|
|
|
|
$results = [];
|
|
|
|
$im = imagecreatetruecolor(100, 100);
|
|
$color = imagecolorallocate($im, 0, 0, 0);
|
|
|
|
function testFont($im, $fontPath, $color) {
|
|
if (!file_exists($fontPath)) {
|
|
return ['error' => 'File does not exist'];
|
|
}
|
|
|
|
$fontResults = [];
|
|
for ($i = 0; $i <= 9; $i++) {
|
|
// Attempt to render the digit using imagettftext
|
|
$res = @imagettftext($im, 12, 0, 10, 50, $color, $fontPath, (string)$i);
|
|
if ($res === false) {
|
|
$fontResults[$i] = 'Failed (returned false)';
|
|
} else {
|
|
$fontResults[$i] = 'Success: ' . json_encode($res);
|
|
}
|
|
}
|
|
return $fontResults;
|
|
}
|
|
|
|
$results['Roboto-Bold.ttf'] = testFont($im, $roboto, $color);
|
|
$results['Lora-Bold.ttf'] = testFont($im, $lora, $color);
|
|
|
|
imagedestroy($im);
|
|
|
|
echo json_encode($results, JSON_PRETTY_PRINT);
|
|
?>
|