Ray
Ray

Reputation: 21905

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?

Upvotes: 0

Views: 1147

Answers (2)

ED MAN
ED MAN

Reputation: 1

I had the same issue and found this answer from Ryan L that worked for me:

Using an admin command prompt, copy the font file(s) to the "c:\windows\fonts" folder. Then edit the registry to add the font file name to the list in (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts) Reboot the machine. I have used this to install a bar code font on our terminal server for our warehouse users.

Link to his answer: https://superuser.com/questions/1463154/install-fonts-on-windows-2019-terminal-server-for-all-users#:~:text=Using%20an%20admin%20command%20prompt,server%20for%20our%20warehouse%20users.

Upvotes: 0

Aristos
Aristos

Reputation: 66641

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.

Upvotes: 1

Related Questions