What is the purpose of determining available server fonts using PHP for PDF generation?

When generating PDFs using PHP, it is important to ensure that the fonts used in the document are available on the server. This is because if the desired font is not available, the PDF generation process may default to a different font, leading to unexpected formatting issues. To avoid this, you can determine the available server fonts using PHP and use only those fonts in your PDF generation.

<?php
// Get the list of available fonts on the server
$fonts = shell_exec('fc-list');

// Print out the list of available fonts
echo $fonts;
?>