use font in mPDF generated document

Notes

Firstly, dont use mpdf1.com website, it's closed. Use https://github.com/mpdf/mpdf. There are different codes for Version 6 and 7

Example for mPDF v6.x

(source)

1) upload MyFont.ttf into /mpdf/ttfonts
2) in /mpdf/config_fonts.php , inside $this->fontdata array, add your:

"my_custom_font" => array( 
        'R' => 'MyFont.ttf',            // Regular - REQUIRED
        'I' => "MyFont-Oblique.ttf",    // Italic  - OPTIONAL
        'B' => "MyFont-Bold.ttf",       // Bold    - OPTIONAL
),


3) then, wherever you execute your custom script, use my_custom_fonttt in css:

<?php

$mpdf=new mPDF();
$texttt= '
    <html><head><style>
    body { font-family: "my_custom_font"; }
    </style></head>
    <body>My SAMPLE TEXTTTTT</body>
    </html>';
$mpdf->WriteHTML("$texttt");
$mpdf->Output(dirname(__FILE__).'/new_created_file.pdf','F');

I've solved my problem, there should be no spaces in the definition of the font, so I replaced in my css font-face declaration with "opensans" and

$this->fontdata = array(
    "opensans" => array(
    'R' => 'OpenSans-Regular.ttf'
    )

be aware that the font type ('OpenSans-Regular.ttf') should be inside ttfonts folder of mpdf folder