在Silverlight 1.1中,使用中文字体时需要使用Downloader从服务器上下载字体(具体请参考这篇文章:在Silverlight中使用中文)。在Silverlight 2中,据说是可以读取系统字体了,都以为可以不用再这么复杂地从服务器上下载字体了。结果有人发现放出来的2.0的Beta版本中无论设置什么字体都只能显示微软雅黑字体(针对中文)。

不过在Silverlight 2中提供了一种更简单的设置字体的方式,不用写长长的Downloader代码了,你只需要这样:

这个是宋体

在编译的时候会自动把相关字体打包成XAP文件放在ClientBin目录下,看起来是不是非常的简单?

通过使用这样的方式:

#

Silverlight会自动创建一个Downloader去下载相应的文件,并设置字体。和Silverlight 1.1中一样,在这里我们也可以使用zip格式的文件,例如:

这个是宋体

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.