2 // Mono.Cairo.TextExtents.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Hisham Mardam Bey (hisham.mardambey@gmail.com)
8 // (C) Ximian, Inc. 2003
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Runtime
.InteropServices
;
36 [StructLayout (LayoutKind
.Sequential
)]
37 public struct TextExtents
46 public double XBearing
{
47 get { return xbearing; }
48 set { xbearing = value; }
51 public double YBearing
{
52 get { return ybearing; }
53 set { ybearing = value; }
58 set { width = value; }
61 public double Height
{
62 get { return height; }
63 set { height = value; }
66 public double XAdvance
{
67 get { return xadvance; }
68 set { xadvance = value; }
71 public double YAdvance
{
72 get { return yadvance; }
73 set { yadvance = value; }
76 public override bool Equals (object obj
)
78 if (obj
is TextExtents
)
79 return this == (TextExtents
)obj
;
83 public override int GetHashCode ()
85 return (int)XBearing ^
(int)YBearing ^
(int)Width ^
(int)Height ^
(int)XAdvance ^
(int)YAdvance
;
88 public static bool operator == (TextExtents extents
, TextExtents other
)
90 return extents
.XBearing
== other
.XBearing
&& extents
.YBearing
== other
.YBearing
&& extents
.Width
== other
.Width
&& extents
.Height
== other
.Height
&& extents
.XAdvance
== other
.XAdvance
&& extents
.YAdvance
== other
.YAdvance
;
93 public static bool operator != (TextExtents extents
, TextExtents other
)
95 return !(extents
== other
);