diff --git a/Source/Utilities/Fonts/Glyph.cs b/Source/Utilities/Fonts/Glyph.cs index c386d739..25470c65 100644 --- a/Source/Utilities/Fonts/Glyph.cs +++ b/Source/Utilities/Fonts/Glyph.cs @@ -16,13 +16,11 @@ namespace OpenTK.Graphics /// /// Represents a single character of a specific Font. /// - class Glyph : IPackable + struct Glyph : IPackable { char character; Font font; SizeF size; - //static Bitmap bmp = new Bitmap(1, 1); - object obj = new object(); #region --- Constructors --- @@ -42,6 +40,8 @@ namespace OpenTK.Graphics #endregion + #region --- Public Methods --- + #region public char Character /// @@ -74,7 +74,52 @@ namespace OpenTK.Graphics #endregion - #region IPackable Members + #region public override bool Equals(object obj) + + /// + /// Checks whether the given object is equal (memberwise) to the current Glyph. + /// + /// The obj to check. + /// True, if the object is identical to the current Glyph. + public override bool Equals(object obj) + { + if (obj is Glyph) + return this.Equals((Glyph)obj); + return base.Equals(obj); + } + + #endregion + + #region public override string ToString() + + /// + /// Describes this Glyph object. + /// + /// Returns a System.String describing this Glyph. + public override string ToString() + { + return String.Format("'{0}', {1} {2}, {3} {4}, ({5}, {6})", Character, Font.Name, font.Style, font.Size, font.Unit, Width, Height); + } + + #endregion + + #region public override int GetHashCode() + + /// + /// Calculates the hashcode for this Glyph. + /// + /// A System.Int32 containing a hashcode that uniquely identifies this Glyph. + public override int GetHashCode() + { + //return character.GetHashCode() ^ font.Style.GetHashCode() ^ font.Size.GetHashCode() ^ font.Unit.GetHashCode(); + return character.GetHashCode() ^ font.GetHashCode() ^ size.GetHashCode(); + } + + #endregion + + #endregion + + #region --- IPackable Members --- /// /// Gets an integer representing the width of the Glyph in pixels. @@ -100,25 +145,7 @@ namespace OpenTK.Graphics #endregion - public override bool Equals(object obj) - { - if (obj is Glyph) - return this.Equals((Glyph)obj); - return base.Equals(obj); - } - - public override string ToString() - { - return String.Format("'{0}', {1} {2}, {3} {4}, ({5}, {6})", Character, Font.Name, font.Style, font.Size, font.Unit, Width, Height); - } - - public override int GetHashCode() - { - //return character.GetHashCode() ^ font.Style.GetHashCode() ^ font.Size.GetHashCode() ^ font.Unit.GetHashCode(); - return character.GetHashCode() ^ font.GetHashCode() ^ size.GetHashCode(); - } - - #region IEquatable Members + #region --- IEquatable Members --- /// /// Compares the current Glyph with the given Glyph.