Struct FontWeight
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
NFloatThe numeric font weight value.
Fields
Black
Font weight 900 – Black. The heaviest available weight.
public static readonly FontWeight Black
Field Value
Bold
Font weight 700 – Bold. Common for emphasis and headings.
public static readonly FontWeight Bold
Field Value
ExtraBold
Font weight 800 – Extra Bold. Heavier than Bold.
public static readonly FontWeight ExtraBold
Field Value
ExtraLight
Font weight 200 – Extra Light. Slightly heavier than Thin.
public static readonly FontWeight ExtraLight
Field Value
Light
Font weight 300 – Light. Common for minimalist design.
public static readonly FontWeight Light
Field Value
Medium
Font weight 500 – Medium. Slightly heavier than normal.
public static readonly FontWeight Medium
Field Value
Normal
Font weight 400 – Normal. Standard weight for body text.
public static readonly FontWeight Normal
Field Value
SemiBold
Font weight 600 – Semi Bold. Between medium and bold.
public static readonly FontWeight SemiBold
Field Value
Thin
Font weight 100 – Thin. The lightest possible weight.
public static readonly FontWeight Thin
Field Value
Value
The numeric value of the font weight.
public readonly NFloat Value
Field Value
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
FontWeightAn 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
objectThe 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
FontWeightAn object to compare with this object.
Returns
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
FontWeightb
FontWeight
Returns
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
FontWeightb
FontWeight
Returns
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
FontWeightb
FontWeight
Returns
implicit operator FontWeight(int)
Implicitly converts an int to FontWeight.
public static implicit operator FontWeight(int value)
Parameters
value
int
Returns
implicit operator FontWeight(NFloat)
Implicitly converts a NFloat to FontWeight.
public static implicit operator FontWeight(NFloat value)
Parameters
value
NFloat
Returns
implicit operator FontWeight(float)
Implicitly converts a float to FontWeight.
public static implicit operator FontWeight(float value)
Parameters
value
float
Returns
implicit operator NFloat(FontWeight)
Implicitly converts a FontWeight to NFloat.
public static implicit operator NFloat(FontWeight weight)
Parameters
weight
FontWeight
Returns
operator !=(FontWeight, FontWeight)
Returns true
if two font weights are not equal.
public static bool operator !=(FontWeight a, FontWeight b)
Parameters
a
FontWeightb
FontWeight
Returns
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
FontWeightb
FontWeight
Returns
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
FontWeightb
FontWeight