Table of Contents

Class LocalizedFontDescription

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly
MonoGame.Framework.Content.Pipeline.dll

Normally, when you add a .spritefont file to your project, this data is deserialized into a FontDescription object, which is then built into a SpriteFontContent by the FontDescriptionProcessor. But to localize the font, we want to add some additional data, so our custom processor can know what .resx files it needs to scan. We do this by defining our own custom font description class, deriving from the built in FontDescription type, and adding a new property to store the resource filenames.

public class LocalizedFontDescription : FontDescription
Inheritance
LocalizedFontDescription
Inherited Members

Constructors

LocalizedFontDescription()

Constructor.

public LocalizedFontDescription()

Properties

ResourceFiles

Add a new property to our font description, which will allow us to include a ResourceFiles element in the .spritefont XML. We use the ContentSerializer attribute to mark this as optional, so existing .spritefont files that do not include this ResourceFiles element can be imported as well.

[ContentSerializer(Optional = true, CollectionItemName = "Resx")]
public List<string> ResourceFiles { get; }

Property Value

List<string>