Table of Contents

Struct FontWeight

Namespace
Xui.Core.Canvas
Assembly
Core.dll

Represents the numeric weight of a font, corresponding to CSS font weights (100–900).

public readonly struct FontWeight : IComparable<FontWeight>, IEquatable<FontWeight>
Implements
Inherited Members

Remarks

Font weights are numeric and allow comparison using operators like <, >=, etc.

Constructors

FontWeight(NFloat)

Creates a new FontWeight with the specified numeric value.

public FontWeight(NFloat value)

Parameters

value NFloat

The numeric font weight value.

Fields

Black

Font weight 900 – Black. The heaviest available weight.

public static readonly FontWeight Black

Field Value

FontWeight

Bold

Font weight 700 – Bold. Common for emphasis and headings.

public static readonly FontWeight Bold

Field Value

FontWeight

ExtraBold

Font weight 800 – Extra Bold. Heavier than Bold.

public static readonly FontWeight ExtraBold

Field Value

FontWeight

ExtraLight

Font weight 200 – Extra Light. Slightly heavier than Thin.

public static readonly FontWeight ExtraLight

Field Value

FontWeight

Light

Font weight 300 – Light. Common for minimalist design.

public static readonly FontWeight Light

Field Value

FontWeight

Medium

Font weight 500 – Medium. Slightly heavier than normal.

public static readonly FontWeight Medium

Field Value

FontWeight

Normal

Font weight 400 – Normal. Standard weight for body text.

public static readonly FontWeight Normal

Field Value

FontWeight

SemiBold

Font weight 600 – Semi Bold. Between medium and bold.

public static readonly FontWeight SemiBold

Field Value

FontWeight

Thin

Font weight 100 – Thin. The lightest possible weight.

public static readonly FontWeight Thin

Field Value

FontWeight

Value

The numeric value of the font weight.

public readonly NFloat Value

Field Value

NFloat

Methods

CompareTo(FontWeight)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(FontWeight other)

Parameters

other FontWeight

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

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.

Equals(FontWeight)

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

public bool Equals(FontWeight other)

Parameters

other FontWeight

An object to compare with this object.

Returns

bool

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

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.

Operators

operator ==(FontWeight, FontWeight)

Returns true if two font weights are equal.

public static bool operator ==(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool

operator >(FontWeight, FontWeight)

Returns true if the left font weight is greater than the right.

public static bool operator >(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool

operator >=(FontWeight, FontWeight)

Returns true if the left font weight is greater than or equal to the right.

public static bool operator >=(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool

implicit operator FontWeight(int)

Implicitly converts an int to FontWeight.

public static implicit operator FontWeight(int value)

Parameters

value int

Returns

FontWeight

implicit operator FontWeight(NFloat)

Implicitly converts a NFloat to FontWeight.

public static implicit operator FontWeight(NFloat value)

Parameters

value NFloat

Returns

FontWeight

implicit operator FontWeight(float)

Implicitly converts a float to FontWeight.

public static implicit operator FontWeight(float value)

Parameters

value float

Returns

FontWeight

implicit operator NFloat(FontWeight)

Implicitly converts a FontWeight to NFloat.

public static implicit operator NFloat(FontWeight weight)

Parameters

weight FontWeight

Returns

NFloat

operator !=(FontWeight, FontWeight)

Returns true if two font weights are not equal.

public static bool operator !=(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool

operator <(FontWeight, FontWeight)

Returns true if the left font weight is less than the right.

public static bool operator <(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool

operator <=(FontWeight, FontWeight)

Returns true if the left font weight is less than or equal to the right.

public static bool operator <=(FontWeight a, FontWeight b)

Parameters

a FontWeight
b FontWeight

Returns

bool