/
pdf-receipt-custom-font.php
64 lines (53 loc) · 1.49 KB
/
pdf-receipt-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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Support other languages with a custom font that supports the font
*
* Notes: Font must be TTF true type format. Be careful testing on localhost due to directory write and permission issues.
*
* @return string
*/
function give_pdf_receipts_support_languages() {
// Font must be .ttf (truetype) format.
$custom_font = 'https://recurring.givewp.com/wp-content/uploads/fonts/SimSun.ttf';
ob_start();
?>
<style>
@font-face {
font-family: 'SimSun';
font-style: normal;
font-weight: normal;
src: url('<?php echo esc_url( $custom_font ); ?>') format('truetype');
}
@font-face {
font-family: 'SimSun';
font-style: italic;
src: url('<?php echo esc_url( $custom_font ); ?>') format('truetype');
}
@font-face {
font-family: 'SimSun';
font-style: italic;
font-weight: bold;
src: url('<?php echo esc_url( $custom_font ); ?>') format('truetype');
}
@font-face {
font-family: 'SimSun';
font-style: normal;
font-weight: bold;
src: url('<?php echo esc_url( $custom_font ); ?>') format('truetype');
}
html, body {
margin: 0;
padding: 0;
}
/* Here we set ALL elements on the page to use the new font family.
You can also specifically target various elements using a class name too
and render more than one font family.
*/
*, body, div, html {
font-family: 'SimSun', sans-serif !important;
}
</style>
<?php
return ob_get_clean();
}
add_filter( 'give_pdf_header_styles', 'give_pdf_receipts_support_languages', 1 );