mirror of
https://github.com/nicoverbruggen/ebook-fonts-showcase.git
synced 2026-03-22 21:10:08 +01:00
- Better UX overall - Fixes for phone in landscape - Added line height option - Use Warbreaker prologue (and added attribution)
34 lines
894 B
PHP
34 lines
894 B
PHP
<?php
|
|
if (!defined('APP_ROOT')) {
|
|
http_response_code(403);
|
|
exit;
|
|
}
|
|
|
|
$fontRoot = APP_ROOT . '/repos/ebook-fonts/fonts';
|
|
$fontEntries = [];
|
|
|
|
$iterator = new RecursiveIteratorIterator(
|
|
new RecursiveDirectoryIterator($fontRoot, FilesystemIterator::SKIP_DOTS)
|
|
);
|
|
|
|
foreach ($iterator as $fileInfo) {
|
|
if (!$fileInfo->isFile()) {
|
|
continue;
|
|
}
|
|
if (strtolower($fileInfo->getExtension()) !== 'ttf') {
|
|
continue;
|
|
}
|
|
if (str_contains($fileInfo->getFilename(), 'NV_OpenDyslexic')) {
|
|
continue;
|
|
}
|
|
$relative = str_replace(APP_ROOT . '/', '', $fileInfo->getPathname());
|
|
$relative = str_replace(DIRECTORY_SEPARATOR, '/', $relative);
|
|
$fontEntries[] = $relative;
|
|
}
|
|
|
|
sort($fontEntries, SORT_NATURAL | SORT_FLAG_CASE);
|
|
$fontFilesJson = json_encode($fontEntries, JSON_UNESCAPED_SLASHES);
|
|
if ($fontFilesJson === false) {
|
|
$fontFilesJson = '[]';
|
|
}
|