forked from mpdf/mpdf-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example67_custom_font.php
33 lines (25 loc) · 819 Bytes
/
example67_custom_font.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
// require composer autoload
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'fontDir' => array_merge($fontDirs, [__DIR__]),
'fontdata' => $fontData + ['angerthas' => [
'R' => 'assets/angerthas.ttf',
]],
'default_font' => 'angerthas'
]);
$mpdf->WriteHtml('<html>
<head>
</head>
<body>
<h1>Using custom font in the document</h1>
<p>This example shows how to keep default font families while adding a custom font directory and definitions.
</body>
</html>');
$mpdf->Output();
die;