baskren / Forms9Patch

Simplify image management and text formatting in your Xamarin.Forms apps
http://Forms9Patch.com
Other
127 stars 33 forks source link

Html to PNG - Custom Font #70

Closed wesoos closed 4 years ago

wesoos commented 4 years ago

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...

baskren commented 4 years ago

Check out this guide:

https://baskren.github.io/Forms9Patch/guides/CustomFonts.html

wesoos commented 4 years ago

Thanks. It seems though this article relates to label, button, and other forms elements. I am using this library to convert raw html source to a png image. In the styling of the html, I'm using a custom font. Is this possible?

Wessel Oosthuizen


From: Ben Askren notifications@github.com Sent: Tuesday, August 11, 2020 9:06:42 AM To: baskren/Forms9Patch Forms9Patch@noreply.github.com Cc: Wessel Oosthuizen wessel@tekwavesolutions.com; Author author@noreply.github.com Subject: Re: [baskren/Forms9Patch] Html to PNG - Custom Font (#70)

Check out this guide:

https://baskren.github.io/Forms9Patch/guides/CustomFonts.html

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/baskren/Forms9Patch/issues/70#issuecomment-671935307, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABXERZUHLSHKUJT3IBFLCLTSAE66FANCNFSM4P2OWZNA.

baskren commented 4 years ago

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.