How do I create a bitmap image as spritefont with multiple character regions?

StackOverflow https://stackoverflow.com/questions/12389197

  •  01-07-2021
  •  | 
  •  

Domanda

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

È stato utile?

Soluzione

There is no XML file.

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.

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

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top