BitmapFontCharacter.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) Craftwork Games. All rights reserved.
  2. // Licensed under the MIT license.
  3. // See LICENSE file in the project root for full license information.
  4. using System.Collections.Generic;
  5. using MonoGame.Extended.Graphics;
  6. namespace MonoGame.Extended.BitmapFonts;
  7. /// <summary>
  8. /// Represents a character in a bitmap font. This class cannot be inherited.
  9. /// </summary>
  10. public sealed class BitmapFontCharacter
  11. {
  12. /// <summary>
  13. /// Gets the character code.
  14. /// </summary>
  15. public int Character { get; }
  16. /// <summary>
  17. /// Gets the texture region that contains the character's image.
  18. /// </summary>
  19. public Texture2DRegion TextureRegion { get; }
  20. /// <summary>
  21. /// Gets the horizontal offset for rendering the character.
  22. /// </summary>
  23. public int XOffset { get; }
  24. /// <summary>
  25. /// Gets the vertical offset for rendering the character.
  26. /// </summary>
  27. public int YOffset { get; }
  28. /// <summary>
  29. /// Gets the horizontal advance value for rendering the next character.
  30. /// </summary>
  31. public int XAdvance { get; }
  32. /// <summary>
  33. /// Gets the dictionary of kerning values for pairs of characters.
  34. /// </summary>
  35. public Dictionary<int, int> Kernings { get; }
  36. /// <summary>
  37. /// Initializes a new instance of the <see cref="BitmapFontCharacter"/> class.
  38. /// </summary>
  39. /// <param name="character">The character code.</param>
  40. /// <param name="textureRegion">The texture region that contains the character's image.</param>
  41. /// <param name="xOffset">The horizontal offset for rendering the character.</param>
  42. /// <param name="yOffset">The vertical offset for rendering the character.</param>
  43. /// <param name="xAdvance">The horizontal advance value for rendering the next character.</param>
  44. public BitmapFontCharacter(int character, Texture2DRegion textureRegion, int xOffset, int yOffset, int xAdvance)
  45. {
  46. Character = character;
  47. TextureRegion = textureRegion;
  48. XOffset = xOffset;
  49. YOffset = yOffset;
  50. XAdvance = xAdvance;
  51. Kernings = new Dictionary<int, int>();
  52. }
  53. }