安装后的Windows字体不是在应用程序立即可用? [英] Windows fonts not immediately useable in application after installing?

查看:130
本文介绍了安装后的Windows字体不是在应用程序立即可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在Windows 2003服务器上安装一个新的字体,我不能立即在我的asp.net web应用程序中使用它。应用程序通过获取字体 CreateFontIndirect GDI32.DLL赢得API,然后使用这个字体在我的asp.net应用程序创建一个动态文本图像。这似乎是字体得到缓存的地方,因为我将刚刚得到的默认字体返回。

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 CreateFontIndirect gdi32.dll win api, and then use this font to create a dynamic text image in my asp.net application. It seems like fonts get cached somewhere, because I will just get the default font returned.

字体缓存被重新启动后更新,然后我得到了正确的字体,但显然我不希望只是为了获得一个新的字体的工作做在生产服务器上重新启动。

The font cache gets updated after a reboot, and then I get the correct font, but obviously I wouldn't like to do a reboot on a production server just for getting a new font to work.

有没有办法来刷新字体缓存?

Is there a way to flush the font cache?

推荐答案

在默认情况下,当你安装一个新的字体,只有的当前会话的通知的改变。所以,如果你登录到服务器的终端服务会话(这似乎很有可能),那么ASP.NET应用程序(这将在不同的会话中运行)将不会看到的变化。

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.

要手动注册一个新的字体,你需要调用的 AddFontResource 并传递路径字体。

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

要使它稍微容易,让您的应用程序扫描字体文件夹,每个文件调用 AddFontResource 找到有没有它,你可以把它的的Application_Start 事件。这样,当你安装一个新的字体,你可以回收站点(例如编辑web.config文件),它会重新扫描所有文件。

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.

另一种选择是把一个目录表(通过<一个href=\"http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx\">FileSystemWatcher)在Fonts文件夹,并自动重新扫描。

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

这篇关于安装后的Windows字体不是在应用程序立即可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆