LocalizedFontDescription.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Microsoft.Xna.Framework.Content;
  2. using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
  3. using System.Collections.Generic;
  4. namespace WpfFontPipeline
  5. {
  6. /// <summary>
  7. /// Normally, when you add a .spritefont file to your project, this data is
  8. /// deserialized into a FontDescription object, which is then built into a
  9. /// SpriteFontContent by the FontDescriptionProcessor. But to localize the
  10. /// font, we want to add some additional data, so our custom processor can
  11. /// know what .resx files it needs to scan. We do this by defining our own
  12. /// custom font description class, deriving from the built in FontDescription
  13. /// type, and adding a new property to store the resource filenames.
  14. /// </summary>
  15. public class LocalizedFontDescription : FontDescription
  16. {
  17. /// <summary>
  18. /// Constructor.
  19. /// </summary>
  20. public LocalizedFontDescription()
  21. : base("Arial", 14, 0)
  22. {
  23. }
  24. /// <summary>
  25. /// Add a new property to our font description, which will allow us to
  26. /// include a ResourceFiles element in the .spritefont XML. We use the
  27. /// ContentSerializer attribute to mark this as optional, so existing
  28. /// .spritefont files that do not include this ResourceFiles element
  29. /// can be imported as well.
  30. /// </summary>
  31. [ContentSerializer(Optional = true, CollectionItemName = "Resx")]
  32. public List<string> ResourceFiles
  33. {
  34. get { return resourceFiles; }
  35. }
  36. List<string> resourceFiles = new List<string>();
  37. }
  38. }