getDefaults(); $fontDirs = $defaultConfig['fontDir']; $newFontDirectory = __DIR__; $config['fontDir'] = array_merge($fontDirs, [$newFontDirectory]); $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); // Note that Mpdf config uses lower-case fontdata // even though it uses camel-case fontDir. $fontdata = $defaultFontConfig['fontdata']; $fontFile = 'ShadowsIntoLight-Regular.ttf'; $config['fontdata'] = $fontdata + [ // lowercase letters only in font key 'shadowsintolight' => [ 'R' => $fontFile, ], ]; return new \Mpdf\Mpdf($config); } }