Windows fonts not immediately useable in application after installing?

后端 未结 3 1389
Happy的楠姐
Happy的楠姐 2021-02-19 17:42

Whenever I install a new font on a Windows 2003 server, I can\'t use it immediately in my asp.net web application. The application gets the font through the CreateFontIndi

相关标签:
3条回答
  • 2021-02-19 17:59

    I recycle the application pool that use the fonts and it fixed.

    0 讨论(0)
  • 2021-02-19 18:14

    By default, when you install a new font, only the current session is notified of the change. So if you're logging into the server in a terminal services session (which seems likely) then the ASP.NET application (which will be running in a different session) will not see the change.

    When you reboot, the system automatically scans the font directory and "registers" all of the fonts in there into the current session.

    To "manually" register a new font, you will need to call AddFontResource and pass in the path to the font.

    To make it slightly easier, you could make it so that your app scans the Fonts folder and calls AddFontResource on each file it finds there in it's Application_Start event. That way, when you install a new font, you can just recycle the site (e.g. edit the web.config file) and it'll re-scan all of the files.

    Another option would be to put a directory watch (via FileSystemWatcher) on the Fonts folder and automatically re-scan it.

    I guess it just depends how often you'll be installing new fonts...

    0 讨论(0)
  • 2021-02-19 18:18

    Restart IIS. that should do the trick. rub iisreset from command line or use IIS manager.

    0 讨论(0)
提交回复
热议问题