$fontData += [
'forum' => [
'R' => 'Forum-Regular.ttf',
]
]
-> this is OK, works with font-family: forum; OR font-family: Forum;
$fontData += [
'Forum' => [
'R' => 'Forum-Regular.ttf',
]
]
-> this is FAILS to work with font-family: forum; or font-family: Forum; or being used as default font.
mPDF 8.0
PHP 7.1
<?php
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$fontData += [
'Forum' => [
'R' => 'Forum-Regular.ttf',
]
];
$mpdf = new Mpdf([
'tempDir' => dirname(dirname(__DIR__)).'/tmp',
'fontDir' => array_merge($fontDirs, [
dirname(dirname(__DIR__)).'/assets/fonts/',
]),
'fontdata' => $fontData,
'mode' => 'utf-8',
'format' => 'A4',
'margin_top' => 10,
'margin_bottom' => 10,
'margin_right' => 15,
'margin_left' => 15,
'orientation' => 'P'
]);
.event .eventInfo {
font-family: Forum;
}
.data {
font-family: forum;
}
Can confirm. Also, thanks @vitexikora that issue saved my day. Have been looking for a mistake in my code for hours.
Not a bug, this is documented. See https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html
Its a trap for developers. I costed me 2-3 hours of debugging, and I doubt that just me. When I told this to my colleagues on our company slack, one just admitted he had the same troubles some time ago, and that he had finally given up and had to switch to a different library, definitely more than 3 hrs. Is it that complicated to call strtolower in the backend?
It is not complicated to call strtolower in the backend. But as always, this is most likely not just calling strtolower in the backend.
But feel free to prepare a pull request.