I'm trying to add Open Sans font to my mpdf document but without success.
In mpdf/config_fonts.php:
$this->fontdata = array(
...
"opensans" => array(
'R' => "OpenSans-Regular.ttf",
'B' => "OpenSans-Semibold.ttf",
'I' => "OpenSans-LightItalic.ttf",
'BI' => "OpenSans-Semibolditalic.ttf"
),
...
);
In the php output file I added this:
<html>
<head>
<style>
body {
font-family: 'Open Sans';
font-size: 10pt;
}
I also already tried to write font-family: opensans, sans-serif;
I uploaded the files into the folder: root/plugins/mpdf/ttfonts/
I think I did everything correctly but didn't work, it use the first sans substitutive font.
Extra info: the mpdf folder is located at his path: root/plugins/ the php file is creating the pdf file is located at this path: root/template/folder/ inside it I declared these:
define('_MPDF_PATH','../../plugins/mpdf/');
include("../../plugins/mpdf/mpdf.php");
probably there is something wrong with the paths, but I don't find the solution.
In addition I can say that If I load the font-family: opensans, sans-serif;, inside the example examples/example02_CSS_styles.php that it works correctly.
How can I solve?
Hi,
The following works for me:
<head>
<style type="text/css">
div,table { font-family: Open Sans, sans-serif !important;}
</style>
</head>
Be sure you are not creating mPDF instance with c $mode parameter as this means core fonts only.
Closing as stale.
Most helpful comment
Be sure you are not creating mPDF instance with
c$modeparameter as this means core fonts only.