This project is read-only.

How to use custom fonts with HtmlRenderer?

Sep 17, 2015 at 5:31 PM
Hi all,

I'm trying to use HtmlRenderer with an HTML that uses customized font, but with no success at all when hosted on the IIS7 server.

I have several scenarios I would like to share with you guys:

1- The one that works when running from my own computer, from Visual Studio (using some kind of IIS Express host process):
I simply installed the font in computer, then I added the FontFamily to the HtmlRenderer by using AddFontFamily(new FontFamily("MyFont")) . In the html , I defined the font-family property for the class in the style section., and then everything works perfectly fine when I execute locally HtmlRenderer.RenderToImageGdiPlus

However, HtmlRenderer throws an exception when I do the same thing on the server (error related to INVALID PARAMETER). If I remove HtmlRenderer.AddFontFamily , it stops throwing the exception, but I dont get to use the font anymore.

2- Trying to embed the FONT in the html (base64)
Embeding Base64 images in the HTML worked for me, but not for base 64 TTF font. The HTML page is fine and loads the embeded when I rendered in the web browser , but this feature does not seems to be supported by HtmlRenderer. For more info on how to do this, you can check

3- Trying to load from font from a local path or web address
None of those worked:
@font-family { font-family: MyFont;
src: url('file:///C:/fonts/myfont.ttf') format('truetype');
src: url('http://localhost/Content/fonts/myfont.ttf') format('truetype');
src: url('') format('truetype');

Do you guys know what I could do to make this work?

Thanks and regards