-
Notifications
You must be signed in to change notification settings - Fork 148
/
example67_custom_font.php
50 lines (38 loc) · 1.14 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// require composer autoload
require_once __DIR__ . '/bootstrap.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',
],
'inkfree' => [
'R' => 'assets/Inkfree.ttf',
],
],
]);
$mpdf->WriteHtml('<html>
<head>
<style>
.inkfree {
font-family: "Ink Free";
}
</style>
</head>
<body>
<h1>Using custom font in the document</h1>
<p style=\'font-family: angerthas\'>This example shows how to keep default font families while adding a custom font directory and definitions.</p>
<p style="font-family: \'Ink Free\'">Inkfree line of text</p>
<p style="font-family: "Ink Free";">Inkfree line of text that is not working</p>
<p style=\'font-family: "Ink Free"\'>Inkfree line of text that is not working</p>
<p class="inkfree">Inkfree line of text</p>
</body>
</html>');
$mpdf->Output();
die;