/* AngelCode bitmap font parsing using C#
* http://www.cyotek.com/blog/angelcode-bitmap-font-parsing-using-csharp
*
* Copyright © 2012-2015 Cyotek Ltd.
*
* Licensed under the MIT License. See license.txt for the full text.
*/
using System;
namespace Cyotek.Drawing.BitmapFont
{
///
/// Represents the font kerning between two characters.
///
internal struct Kerning : IEquatable
{
#region Constructors
///
/// Constructor.
///
/// The first character.
/// The second character.
///
/// How much the x position should be adjusted when drawing the second
/// character immediately following the first.
///
public Kerning(char firstCharacter, char secondCharacter, int amount)
: this()
{
FirstCharacter = firstCharacter;
SecondCharacter = secondCharacter;
Amount = amount;
}
#endregion
#region Properties
///
/// Gets or sets how much the x position should be adjusted when drawing the second character immediately following the
/// first.
///
///
/// How much the x position should be adjusted when drawing the second character immediately following the first.
///
public int Amount { get; set; }
///
/// Gets or sets the first character.
///
///
/// The first character.
///
public char FirstCharacter { get; set; }
///
/// Gets or sets the second character.
///
///
/// The second character.
///
public char SecondCharacter { get; set; }
#endregion
#region Methods
///
/// Returns the fully qualified type name of this instance.
///
///
/// A containing a fully qualified type name.
///
///
public override string ToString()
{
return string.Format("{0} to {1} = {2}", FirstCharacter, SecondCharacter, Amount);
}
///
/// Check if the object represents kerning between the same two characters.
///
///
///
/// Whether or not the object represents kerning between the same two characters.
///
public override bool Equals(object obj)
{
if (obj == null) return false;
if (obj.GetType() != typeof(Kerning)) return false;
return Equals((Kerning)obj);
}
///
/// Check if the other kerning is between the same two characters.
///
///
///
/// Whether or not the other kerning is between the same two characters.
///
public bool Equals(Kerning other)
{
return FirstCharacter == other.FirstCharacter && SecondCharacter == other.SecondCharacter;
}
///
/// Return the hash code of the kerning between the two characters.
///
///
/// A unique hash code of the kerning between the two characters.
///
public override int GetHashCode()
{
return (FirstCharacter << 16) | SecondCharacter;
}
#endregion
}
}