36 lines
915 B
PHP
36 lines
915 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
$fontDir = realpath(__DIR__ . '/../fonts');
|
|
$files = ['Roboto-Bold.ttf', 'Lora-Bold.ttf'];
|
|
$results = [];
|
|
|
|
foreach ($files as $file) {
|
|
$path = $fontDir . '/' . $file;
|
|
if (file_exists($path)) {
|
|
$fp = fopen($path, 'rb');
|
|
$bytes = fread($fp, 16);
|
|
fclose($fp);
|
|
|
|
$hex = [];
|
|
$ascii = '';
|
|
for ($i = 0; $i < strlen($bytes); $i++) {
|
|
$h = sprintf('%02x', ord($bytes[$i]));
|
|
$hex[] = $h;
|
|
$c = ord($bytes[$i]);
|
|
$ascii .= ($c >= 32 && $c <= 126) ? $bytes[$i] : '.';
|
|
}
|
|
|
|
$results[$file] = [
|
|
'size' => filesize($path),
|
|
'first_16_hex' => implode(' ', $hex),
|
|
'first_16_ascii' => $ascii
|
|
];
|
|
} else {
|
|
$results[$file] = 'File not found';
|
|
}
|
|
}
|
|
|
|
echo json_encode($results, JSON_PRETTY_PRINT);
|
|
?>
|