'Font family issue in dompdf

I'm using DOMPDF v0.8.0

I'm having a problem with this library. I'm using this dompdf library with codeigniter2.

I need to implement digital signature and convert the html into pdf. This signature section have different fonts. I'm using google fonts for signature.

I'd added this font to html

<link href="https://fonts.googleapis.com/css?family=Herr+Von+Muellerhoff" rel="stylesheet">

And added the font-family to a particular <span> tag.

<span style='font-family: Herr Von Muellerhoff;'> test sign </span>

But now I'm getting the whole pdf page in which this <span> tag exist having this font family. Remaining pages have default fonts.

I also tried with <font> tag but no success

<font face='Herr Von Muellerhoff'> test sign </font>

Can anyone help me out from this?



Solution 1:[1]

  1. get the css with: wget https://fonts.googleapis.com/css2\?family\=Herr+Von+Muellerhoff:wght@300\;400\;700 and you get:

    @font-face { font-family: 'Herr Von Muellerhoff'; font-style: normal; font-weight: 400; src: url(https://fonts.gstatic.com/s/herrvonmuellerhoff/v13/WBL6rFjRZkREW8WqmCWYLgCkQKXb4CAft3c6.ttf) format('truetype'); }

2 Add css to your dompdf template

3 get zip font file from google fonts : https://fonts.google.com/specimen/Herr+Von+Muellerhoff (click on download family button) and copy the content zip file to your storage/fonts on your laravel directory

  1. Enjoy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Giovanny Canasto