baskren/Forms9Patch

Html to PNG - Custom Font

Closed this issue · 3 comments

Hi, how would I use a custom font with the html code that I want to convert to an image? The font is a barcode font I need...

oh, you are living on the edge.

Short answer: likely.

Long Answer:

The most direct (and fool proof) approach is to embed the custom font into your html file. Something I am not an expert in but I know it can be done - with a bit of effort (Google is your friend). For example: https://gero3.github.io/facetype.js/.

Because the direct approach is very labor intensive, I built (but not documented) EmbeddedHtmlViewSource class. I highly recommend taking a look at the source code. I haven't adapted it to fonts, but it does handle images - so, with a little work, it could be extended to work with fonts.