如何将位图图像创建为具有多个字符区域的 spritefont? [英] How do I create a bitmap image as spritefont with multiple character regions?

查看:35
本文介绍了如何将位图图像创建为具有多个字符区域的 spritefont?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建包含来自多个区域的字符并由 XNA 内容管道正确解释的位图字体图像?

How do I create a bitmap font image that contains characters from multiple regions and is correctly interpreted by XNA content pipeline?

我想在位图字体图像中添加一些特殊字符,但我不知道如何正确操作.

I want to add some special characters to my bitmap font image, but I don't know how to do it correctly.

UPD:我想我离我的答案越来越近了.Sprite 字体纹理内容处理器在图像中查找非洋红色方块,并且可能使用一个 xml 设置文件,就像普通的 spritefonts 一样,将每个方块映射到相应的符号.我可能应该为我的自定义纹理编辑那个 xml 文件,但我不知道在哪里可以找到它.

UPD: I think I'm getting closer to my answer. Sprite font texture content processor looks for non-magenta squares in the image and probably uses an xml settings file like with normal spritefonts to map each square to a corresponding symbol. I should probably edit that xml file for my custom texture, but I don't know where I can find it yet.

推荐答案

没有 XML 文件.

您必须创建自定义内容处理器.从 FontTextureProcessor 继承该处理器并覆盖 GetCharacterForIndex 方法.

You have to create a custom content processor. Inherit that processor from FontTextureProcessor and override the GetCharacterForIndex method.

让您的方法返回纹理中指定索引的字符.

Have your method return the character for the specified index in your texture.

默认实现只返回FirstCharacter + index.你可以使用它喜欢的任何逻辑.(我想你甚至可以让它解析数据的 XML 文件.)

The default implementation simply returns FirstCharacter + index. Yours can use whatever logic it likes. (I guess you could even make it parse an XML file for the data.)

(请注意,对于单个区域,您可以在Sprite Font Texture"内容处理器的属性中指定 FirstCharacter 是什么,在该内容文件的属性窗口 (F4) 中.)

(Note that, for a single region, you can specify what FirstCharacter is in the properties for the "Sprite Font Texture" content processor, in the properties window (F4) for that content file.)

这篇关于如何将位图图像创建为具有多个字符区域的 spritefont?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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