node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Loading custom fonts

Open inamvar opened this issue 6 years ago • 3 comments

I'm using Persian fonts like IRANSANS. can I import my custom font ?

inamvar avatar Feb 19 '18 07:02 inamvar

This can help you https://github.com/marcbachmann/node-html-pdf/issues/322#issuecomment-327045134

joassouza avatar Feb 20 '18 12:02 joassouza

I had the same problem and solved it by using file:// in my html code, for example, I imported my font-face declration css file in them main like this: <style> @import url("file:///home/myname/projects/myprojectname/public/font/IRANSansWeb/index.css"); </style> the base option doesn't word for me.

hosseinnedaee avatar Dec 20 '20 09:12 hosseinnedaee

If you use docker, this solution works

  1. install fonts globally
COPY ./my-custom-font.ttf ./
RUN mkdir -p /usr/share/fonts/truetype/
RUN install -m644 my-custom-font.ttf /usr/share/fonts/truetype/
RUN rm ./my-custom-font.ttf
  1. just use this font in font-family without imports

Dozalex avatar Aug 07 '22 19:08 Dozalex