从代码中安装字体 [英] Install fonts from within the code

查看:198
本文介绍了从代码中安装字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的XNA游戏中使用自定义字体。
正如你可能想象的那样,如果字体没有安装在PC上,游戏就不会启动。
我打算使用try / catch来理解字体是否已安装。



现在有没有办法从码?
您可以记住字体文件位于Content文件夹中。

解决方案

您的字体转换为BMP spritefont,导入BMP图像并在属性中的内容处理器中从纹理更改为雪碧字体纹理。
您可以看到这里可以做到这一点。


I'm currently using a custom font in my XNA game. As you might imagine, the game wont start if the font isn't installed on the PC. I'm planning on using try/catch to understand whether the font's installed or not.

Now, is there a way to install the font from within the code? You can take in mind that the font file is in the Content folder.

解决方案

What you can do is convert your font to a BMP spritefont, import the BMP image and change from "Texture" to "Sprite Font Texture" at the Content Processor in the properties. You can see Here how you can do this.

这篇关于从代码中安装字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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