LocalizedFontDescription.cs 1.9 KB

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