如何在 XNA 游戏中更改字体大小? [英] how to change fontsize during the game in XNA?

查看:36
本文介绍了如何在 XNA 游戏中更改字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用不同字体大小的 spritefont,我必须为每个大小创建新的 spritefont 吗?

I need to use different fontsize of spritefont, Have to I create new spritefont for the each size?

推荐答案

基本上是.

SpriteBatch.DrawString 有一个过载,它给出了您可以选择缩放文本.

There is an overload of SpriteBatch.DrawString that gives you an option to scale your text.

然而,这样做的主要缺点是您的文本在放大时会变得像素化.如果您从更高的分辨率开始并按比例缩小,随着尺寸变小,您将开始获得人工制品.

However the major downside to this is that your text will become pixelated as you scale it up. If you start at a higher resolution and scale down you will start to get artefacts as you get to smaller sizes.

因此,如果您有固定数量的大小,您应该以您需要的不同大小创建多个版本的精灵字体.

So if you have a fixed number of sizes, you should create multiple versions of your sprite font at the different sizes you require.

如果您想要具有锐利边缘的连续可缩放文本,您或许可以查看矢量字体.Nuclex 框架有一些代码.

If you want continuously scalable text with sharp edges, you could perhaps look into vector fonts. The Nuclex Framework has some code to do that.

这篇关于如何在 XNA 游戏中更改字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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