Table of Contents

Struct FontRectangle

Namespace
SixLabors.Fonts
Assembly
SixLabors.Fonts.dll

Stores a set of four single precision floating points that represent the location and size of a rectangle.

public readonly struct FontRectangle : IEquatable<FontRectangle>
Implements
Inherited Members

Constructors

FontRectangle(Vector2, Vector2)

Initializes a new instance of the FontRectangle struct.

public FontRectangle(Vector2 point, Vector2 size)

Parameters

point Vector2

The Vector2 which specifies the rectangles point in a two-dimensional plane.

size Vector2

The Vector2 which specifies the rectangles height and width.

FontRectangle(float, float, float, float)

Initializes a new instance of the FontRectangle struct.

public FontRectangle(float x, float y, float width, float height)

Parameters

x float

The horizontal position of the rectangle.

y float

The vertical position of the rectangle.

width float

The width of the rectangle.

height float

The height of the rectangle.

Fields

Empty

Represents a FontRectangle that has X, Y, Width, and Height values set to zero.

public static readonly FontRectangle Empty

Field Value

FontRectangle

Properties

Bottom

Gets the y-coordinate of the bottom edge of this FontRectangle.

public float Bottom { get; }

Property Value

float

Height

Gets the height of this FontRectangle.

public float Height { get; }

Property Value

float

Left

Gets the x-coordinate of the left edge of this FontRectangle.

public float Left { get; }

Property Value

float

Right

Gets the x-coordinate of the right edge of this FontRectangle.

public float Right { get; }

Property Value

float

Top

Gets the y-coordinate of the top edge of this FontRectangle.

public float Top { get; }

Property Value

float

Width

Gets the width of this FontRectangle.

public float Width { get; }

Property Value

float

X

Gets the x-coordinate of this FontRectangle.

public float X { get; }

Property Value

float

Y

Gets the y-coordinate of this FontRectangle.

public float Y { get; }

Property Value

float

Methods

Center(in FontRectangle)

Returns the center point of the given FontRectangle.

public static Vector2 Center(in FontRectangle rectangle)

Parameters

rectangle FontRectangle

The rectangle.

Returns

Vector2

The Vector2.

Contains(in FontRectangle)

Determines if the rectangular region represented by rectangle is entirely contained within the rectangular region represented by this FontRectangle .

public bool Contains(in FontRectangle rectangle)

Parameters

rectangle FontRectangle

The rectangle.

Returns

bool

The bool.

Contains(Vector2)

Determines if the specified point is contained within the rectangular region defined by this FontRectangle .

public bool Contains(Vector2 point)

Parameters

point Vector2

The point.

Returns

bool

The bool.

Contains(float, float)

Determines if the specified point is contained within the rectangular region defined by this FontRectangle.

public bool Contains(float x, float y)

Parameters

x float

The x-coordinate of the given point.

y float

The y-coordinate of the given point.

Returns

bool

The bool.

Deconstruct(out float, out float, out float, out float)

Deconstructs this rectangle into four floats.

public void Deconstruct(out float x, out float y, out float width, out float height)

Parameters

x float

The out value for X.

y float

The out value for Y.

width float

The out value for the width.

height float

The out value for the height.

Equals(FontRectangle)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(FontRectangle other)

Parameters

other FontRectangle

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromLTRB(float, float, float, float)

Creates a new FontRectangle with the specified location and size.

public static FontRectangle FromLTRB(float left, float top, float right, float bottom)

Parameters

left float

The left coordinate of the rectangle.

top float

The top coordinate of the rectangle.

right float

The right coordinate of the rectangle.

bottom float

The bottom coordinate of the rectangle.

Returns

FontRectangle

The FontRectangle.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Inflate(in FontRectangle, float, float)

Creates a new FontRectangle from the given rectangle that is inflated by the specified amount.

public static FontRectangle Inflate(in FontRectangle rectangle, float x, float y)

Parameters

rectangle FontRectangle

The rectangle.

x float

The amount to inflate the width by.

y float

The amount to inflate the height by.

Returns

FontRectangle

A new FontRectangle.

Inflate(Vector2)

Creates a new FontRectangle inflated by the specified amount.

public FontRectangle Inflate(Vector2 size)

Parameters

size Vector2

The size.

Returns

FontRectangle

New FontRectangle representing the inflated rectangle

Inflate(float, float)

Creates a new FontRectangle inflated by the specified amount.

public FontRectangle Inflate(float width, float height)

Parameters

width float

The width.

height float

The height.

Returns

FontRectangle

New FontRectangle representing the inflated rectangle

Intersect(in FontRectangle)

Creates a FontRectangle that represents the intersection between this FontRectangle and the rectangle.

public FontRectangle Intersect(in FontRectangle rectangle)

Parameters

rectangle FontRectangle

The rectangle.

Returns

FontRectangle

New FontRectangle representing the intersections between the two rectangles.

Intersect(in FontRectangle, in FontRectangle)

Creates a rectangle that represents the intersection between a and b. If there is no intersection, an empty rectangle is returned.

public static FontRectangle Intersect(in FontRectangle a, in FontRectangle b)

Parameters

a FontRectangle

The first rectangle.

b FontRectangle

The second rectangle.

Returns

FontRectangle

The FontRectangle.

IntersectsWith(in FontRectangle)

Determines if the specified FontRectangle intersects the rectangular region defined by this FontRectangle.

public bool IntersectsWith(in FontRectangle rectangle)

Parameters

rectangle FontRectangle

The other rectangle.

Returns

bool

The bool.

Offset(Vector2)

Adjusts the location of this rectangle by the specified amount.

public FontRectangle Offset(Vector2 point)

Parameters

point Vector2

The point.

Returns

FontRectangle

New FontRectangle representing the offset rectangle.

Offset(float, float)

Adjusts the location of this rectangle by the specified amount.

public FontRectangle Offset(float dx, float dy)

Parameters

dx float

The amount to offset the x-coordinate.

dy float

The amount to offset the y-coordinate.

Returns

FontRectangle

New FontRectangle representing the inflated rectangle.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Transform(in FontRectangle, Matrix3x2)

Creates a new FontRectangle by transforming the given rectangle by the given matrix.

public static FontRectangle Transform(in FontRectangle rectangle, Matrix3x2 matrix)

Parameters

rectangle FontRectangle

The source rectangle.

matrix Matrix3x2

The transformation matrix.

Returns

FontRectangle

A transformed FontRectangle.

Union(in FontRectangle, in FontRectangle)

Creates a rectangle that represents the union between a and b.

public static FontRectangle Union(in FontRectangle a, in FontRectangle b)

Parameters

a FontRectangle

The first rectangle.

b FontRectangle

The second rectangle.

Returns

FontRectangle

The FontRectangle.

Operators

operator ==(in FontRectangle, in FontRectangle)

Compares two FontRectangle objects for equality.

public static bool operator ==(in FontRectangle left, in FontRectangle right)

Parameters

left FontRectangle

The FontRectangle on the left side of the operand.

right FontRectangle

The FontRectangle on the right side of the operand.

Returns

bool

True if the current left is equal to the right parameter; otherwise, false.

operator !=(in FontRectangle, in FontRectangle)

Compares two FontRectangle objects for inequality.

public static bool operator !=(in FontRectangle left, in FontRectangle right)

Parameters

left FontRectangle

The FontRectangle on the left side of the operand.

right FontRectangle

The FontRectangle on the right side of the operand.

Returns

bool

True if the current left is unequal to the right parameter; otherwise, false.