I am using Dompdf to generate and send a PDF via email from my Wordpress site. I am attempting to use a custom font and the normal font-weight is working correctly, but bold is not.
Here's what my HTML variable looks like:
$html =
'<html>
<body>
<style>
@font-face {
font-family: "Proxima Nova";
font-weight: normal;
font-style: normal;
src: url(' . get_template_directory() . '/fonts/ProximaNova-Reg.woff2) format("woff2"), url(' . get_template_directory() . '/fonts/ProximaNova-Reg.woff) format("woff");
}
@font-face {
font-family: "Proxima Nova";
font-weight: bold;
font-style: normal;
src: url(' . get_template_directory() . '/fonts/ProximaNova-Bold.woff2) format("woff2"), url(' . get_template_directory() . '/fonts/ProximaNova-Bold.woff) format("woff");
}
body,html {font-family:"Proxima Nova";}
</style>
<table>
<thead>
<tr>
<th>Test</th>
<th>Test</th>
<th>Test</th>
</tr>
</thead>
<tbody>
<tr>
<td>Test</td>
<td>Test</td>
<td>Test</td>
</tr>
</tbody>
</table>
</body>
</html>';
When I open the generated PDF, the tds are correctly displayed in the Proxima Nova font, but the ths are not. The weird thing is that if I just email the HTML to myself using wp_mail the bold font works correctly. It's only in the PDF that it doesn't work. Any ideas?
Screenshot from the email:

Screenshot from the PDF:

I do not have the font installed locally
I figured out the issue, at one point I was using the TrueType version of the normal font weight but not the bold. Apparently php-font-lib can only generate the compatible fonts from a ttf file and not woff. When I switched both declarations over to ttf it generated the necessary files and now both weights are working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With