Search code examples
c#asp.netfonts

Why is font not available in ASP.NET code?


I have an ASP.NET site where I generate ID cards for users. I use a Bitmap object and call Graphics.DrawString to write various bits of text on the image. I have used various fonts to do this for quite a while, without any fuss.

A customer has now asked me to use the Roboto font for their card. I downloaded it from Google and installed it on my system - it appears in the control panel and is available to other apps. However, my card generator can't access it - it defaults to Microsoft Sans Serif. I used foreach (FontFamily family in FontFamily.Families) to see if it was listed, and it was not included in the list. I tried the same thing in a WinForms app, and the font was included in the list.

So, my question is, why can't I access this font from within an ASP.NET process? Is there some difference in the way fonts are supported between ASP.NET and WinForms?


Solution

  • Because the asp.net is run under specific pool, and this pool is logged in as different user - that probably have not installed that fonts.

    So check under which user your pool is run, and install for that user that font.