I have tried like many times to use a custom font (nepali font called Mangal) in mpdf but the font doesn't show properly. I was wondering if someone has done in the past to share some tips on how to sort this out. When i try to 'useOTL' => 0xFF the pdf keeps loading until the server times out. below a simple code i have tested in different versions
<?php
// ini_set("memory_limit","128M");
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
use Mpdf\Config\ConfigVariables;
use Mpdf\Config\FontVariables;
use Mpdf\Mpdf;
// $mpdf = new Mpdf();
$fontDirectory = __DIR__ . '/CustomFonts';
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new Mpdf([
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/customFonts',
]),
'fontdata' => $fontData + [
'mangal' => [
'R' => 'mangalone.ttf',
// 'useOTL' => 0xFF, if this is disabled the font display but properly
],
],
'default_font' => 'mangal',
]);
$html = '
<h1 style="font-family: mangal">नमस्ते, म एक एआई साथी हुँ। -- कम्पनीको नाम</h1>
<p style="font-family: mangal">मेरो नाम कोपाइलोट हो। म तपाईंलाई विभिन्न कुराहरूमा मद्दत गर्न सक्छु।</p>
';
// Read and Parse HTML Content
$mpdf->WriteHTML($html);
// Display PDF to Browser
$mpdf->Output();
Any help will be really appreciated. Thanks
I tried to use a custom nepali font called Mangal in mpdf but doesn't work properly, the font is not displayed properly and if i enable useOTL' => 0xFF then the server timesout and nothing is rendered.