Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font file Eeyek.ttf is missing from default fonts #209

Closed
ve3 opened this issue Feb 24, 2025 · 2 comments
Closed

Font file Eeyek.ttf is missing from default fonts #209

ve3 opened this issue Feb 24, 2025 · 2 comments

Comments

@ve3
Copy link

ve3 commented Feb 24, 2025

I use this code to show all default fonts from mpdf.

<?php
require 'vendor/autoload.php';


$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];

function isFontExists(string $fontFile, array $fontDirs)
{
    $found = false;
    foreach ($fontDirs as $fontDir) {
        if (is_file($fontDir . DIRECTORY_SEPARATOR . $fontFile)) {
            $found = true;
            break;
        }
    }// endforeach;
    unset($fontDir);

    if (false === $found) {
        return '<br><span style="color: red;">Font file is not found.</span>';
    }
}// isFontExists
?>
<!DOCTYPE html>
<html>
    <head>
        <style>
            table {
                border: 1px solid #000;
                border-collapse: collapse;
                width: 100%;
            }
            td, th {
                border: 1px solid #000;
                padding: 5px;
                text-align: left;
                vertical-align: top;
            }
        </style>
    </head>
    <body>
<?php

echo '<h3>Font directories</h3>';
if (is_iterable($fontDirs)) {
    echo '<ul>' . PHP_EOL;
    foreach ($fontDirs as $fontDir) {
        echo '<li>' . $fontDir . ' (' . realpath($fontDir) . ')</li>' . PHP_EOL;
    }// endforeach;
    echo '</ul>' . PHP_EOL;
}// endif;
unset($fontDir);
unset($defaultConfig);

echo '<h3>Font data</h3>' . PHP_EOL;
if (is_iterable($fontData)) {
    echo '<table>' . PHP_EOL;
    echo '<thead>' . PHP_EOL;
    echo '<tr>' . PHP_EOL;
    echo '<th rowspan="2">Font name</th>' . PHP_EOL;
    echo '<th colspan="4">Font file names</th>' . PHP_EOL;
    echo '<th rowspan="2">Font data</th>' . PHP_EOL;
    echo '</tr>' . PHP_EOL;
    echo '<tr>' . PHP_EOL;
    echo '<th>Regular</th>' . PHP_EOL;
    echo '<th>Bold</th>' . PHP_EOL;
    echo '<th>Italic</th>' . PHP_EOL;
    echo '<th>Bold Italic</th>' . PHP_EOL;
    echo '</tr>' . PHP_EOL;
    echo '</thead>' . PHP_EOL;

    echo '<tbody>' . PHP_EOL;
    foreach ($fontData as $fontName => $data) {
        echo '<tr>' . PHP_EOL;
        echo '<td>' . $fontName . '</td>' . PHP_EOL;
        echo '<td>' . ($data['R'] ?? '') . (isset($data['R']) ? isFontExists($data['R'], $fontDirs) : '') . '</td>' . PHP_EOL;
        echo '<td>' . ($data['B'] ?? '') . (isset($data['B']) ? isFontExists($data['B'], $fontDirs) : '') . '</td>' . PHP_EOL;
        echo '<td>' . ($data['I'] ?? '') . (isset($data['I']) ? isFontExists($data['I'], $fontDirs) : '') . '</td>' . PHP_EOL;
        echo '<td>' . ($data['BI'] ?? '') . (isset($data['BI']) ? isFontExists($data['BI'], $fontDirs) : '') . '</td>' . PHP_EOL;
        unset($data['R'], $data['I'], $data['B'], $data['BI']);
        echo '<td>' . nl2br(htmlspecialchars(var_export($data, true), ENT_QUOTES)) . '</td>' . PHP_EOL;
        echo '</tr>' . PHP_EOL;
    }// endforeach;
    unset($data, $fontName);
    echo '</tbody>' . PHP_EOL;
    echo '</table>' . PHP_EOL;
}
unset($defaultFontConfig, $fontData);
unset($fontDirs);
?>
    </body>
</html>

The font name eeyekunicode or file name Eeyek.ttf is not found anywhere in the package. Maybe delete this from default fonts list?

@finwe
Copy link
Member

finwe commented Feb 24, 2025

Thanks for reporting, you are right, will remove. Please note you are reporting this in a wrong repository, please use https://github.com/mpdf/mpdf next time.

@finwe finwe closed this as completed Feb 24, 2025
@finwe
Copy link
Member

finwe commented Feb 24, 2025

Eventually, I solved it by providing the font in the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants