Download the Sun-ExtA and Sun-ExtB fonts from mPDF site and copy them to ‘vendor/mpdf/mpdf/ttfonts/’.
Edit the file ‘vendor/mpdf/mpdf/scr/Config/ConfigVariables.php’ and in the “AUTOMATIC FONT SELECTION” section, set to true the variables ‘autoScriptToLang’ and ‘autoLangToFont’ as in,
// AUTOMATIC FONT SELECTION
// Based on script and/or language
// mPDF 6.0 (similar to previously using function SetAutoFont() )
// 'autoScriptToLang' => false,
'autoScriptToLang' => true,
'baseScript' => Ucdn::SCRIPT_LATIN,
'autoVietnamese' => true,
'autoArabic' => true,
// mPDF 6.0 (similar to old useLang)
// 'autoLangToFont' => false,
'autoLangToFont' => true,
Beware that (as of now) the Sun-Ext fonts are not embedded in the resulting pdf file, and that displaying the japanese characters requires having a proper local font file available to substitute Sun-Ext fonts.
I am investigating this possibility. As of now, the proposed changes to the configuration file cause the XB Riyaz fonts to be embedded in the pdf file, while the Sun-Ext* fonts are not. Thus, there must be another configuration option involved that I haven’t found yet (it is a quite long list).
No matter what options I have tried, I haven’t managed to make mPDF to embed the Sun-Ext* fonts or a subset of it in the pdf file. I only managed to get the font embedded by adding the ‘sun-extb’ value to the ‘font-family’ property in the ‘template.css’ file, but then only the Japanese characters were displayed and all other text was lost, and I presume that’s not what you wanted.
A solution that may work, but I haven’t tested, would be: to create a custom field for the text in Japanese, and then modify a copy of the pdf template to display the custom field using the Japanese font as explained here. The
Another alternative is to process the pdf with a software that embeds the fonts. For instance, you could use the ‘pdftocairo’ tool of the Poppler library (Windows version here) as in,