Table of Contents

Struct GlyphFormat

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

Defines the formatting applied to characters in RichText and ITextBoard. Includes color, font, style, size, and alignment.

public struct GlyphFormat : IEquatable<GlyphFormat>
Implements

Examples

public static readonly GlyphFormat basicRed = new GlyphFormat(textSize: 1.0f, color: Color.Red);
public static readonly GlyphFormat fancyRed = basicRed.WithFont("AbhayaLibreMedium");
public static readonly GlyphFormat sansSerifHeader = new GlyphFormat(Color.LightBlue, TextAlignment.Center, 1.4f, "BitstreamVeraSans");
public static readonly GlyphFormat fluentPurple = GlyphFormat.White.
    WithColor(Color.Purple).
    WithSize(0.8f);

Constructors

GlyphFormat(GlyphFormat)

Copy constructor. Creates a new independent copy of the given format.

public GlyphFormat(GlyphFormat original)

Parameters

original GlyphFormat

GlyphFormat(Color, TextAlignment, float, FontStyles, IFontMin)

Creates a new GlyphFormat using an IFontMin instance and style.

public GlyphFormat(Color color = default, TextAlignment alignment = TextAlignment.Left, float textSize = 1, FontStyles style = FontStyles.Regular, IFontMin font = null)

Parameters

color Color

Text color. Defaults to black.

alignment TextAlignment

Text alignment. Defaults to Left.

textSize float

Text size. Defaults to 1.0f ~= 12pts.

style FontStyles

Font style. Defaults to Regular.

font IFontMin

Font instance. Defaults to the system default font if null.

GlyphFormat(Color, TextAlignment, float, string, FontStyles)

Creates a new GlyphFormat using a font name string.

public GlyphFormat(Color color, TextAlignment alignment, float textSize, string fontName, FontStyles style = FontStyles.Regular)

Parameters

color Color

Text color. Defaults to black if unspecified.

alignment TextAlignment

Text alignment.

textSize float

Text size normalized to 1.0f ~= 12pts.

fontName string

Name of the font registered in FontManager.

style FontStyles

Font style (Regular, Bold, Italic, etc.).

GlyphFormat(Color, TextAlignment, float, Vector2I)

Creates a new GlyphFormat using raw font/style indices.

public GlyphFormat(Color color, TextAlignment alignment, float textSize, Vector2I fontStyle)

Parameters

color Color
alignment TextAlignment
textSize float
fontStyle Vector2I

Fields

Black

Black text using default font and regular style.

public static readonly GlyphFormat Black

Field Value

GlyphFormat

Blueish

Light blue-ish text commonly used for highlighted or neutral UI elements.

public static readonly GlyphFormat Blueish

Field Value

GlyphFormat

Empty

Empty/invalid format. All fields are default/zero.

public static readonly GlyphFormat Empty

Field Value

GlyphFormat

White

White text using default font and regular style.

public static readonly GlyphFormat White

Field Value

GlyphFormat

Properties

Alignment

Text alignment for this format (Left, Center, or Right).

public TextAlignment Alignment { get; }

Property Value

TextAlignment

Color

The color of the text.

public Color Color { get; }

Property Value

Color

Font

The font used by this format, retrieved from the global FontManager.

public IFontMin Font { get; }

Property Value

IFontMin

FontStyle

The specific style (Regular, Bold, Italic, etc.) applied to the font.

public FontStyles FontStyle { get; }

Property Value

FontStyles

StyleIndex

Combined font index and style index as a Vector2I (X = font index, Y = style index).

public Vector2I StyleIndex { get; }

Property Value

Vector2I

TextSize

Scale multiplier for text size. 1.0f ~= 12pts

public float TextSize { get; }

Property Value

float

Methods

Equals(GlyphFormat)

Determines whether this format is equal to another GlyphFormat. Two formats are equal if all fields match exactly.

public bool Equals(GlyphFormat format)

Parameters

format GlyphFormat

Returns

bool

Equals(object)

Determines whether this format is equal to another object.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

Returns a hash code for this format.

public override int GetHashCode()

Returns

int

WithAlignment(TextAlignment)

Returns a new GlyphFormat with the specified alignment.

public GlyphFormat WithAlignment(TextAlignment textAlignment)

Parameters

textAlignment TextAlignment

Returns

GlyphFormat

WithColor(Color)

Returns a new GlyphFormat with the specified color.

public GlyphFormat WithColor(Color color)

Parameters

color Color

Returns

GlyphFormat

WithFont(IFontMin, FontStyles)

Returns a new GlyphFormat using the specified font and style.

public GlyphFormat WithFont(IFontMin font, FontStyles style = FontStyles.Regular)

Parameters

font IFontMin
style FontStyles

Returns

GlyphFormat

WithFont(int)

Returns a new GlyphFormat using the font at the given index (style unchanged).

public GlyphFormat WithFont(int font)

Parameters

font int

Returns

GlyphFormat

WithFont(string, FontStyles)

Returns a new GlyphFormat using the font with the specified name and style.

public GlyphFormat WithFont(string fontName, FontStyles style = FontStyles.Regular)

Parameters

fontName string
style FontStyles

Returns

GlyphFormat

WithFont(Vector2I)

Returns a new GlyphFormat using the specified font/style index pair.

public GlyphFormat WithFont(Vector2I fontStyle)

Parameters

fontStyle Vector2I

Returns

GlyphFormat

WithSize(float)

Returns a new GlyphFormat with the specified text size.

public GlyphFormat WithSize(float size)

Parameters

size float

Returns

GlyphFormat

WithStyle(FontStyles)

Returns a new GlyphFormat with the specified style applied, if the current font supports it. Otherwise returns the original format unchanged.

public GlyphFormat WithStyle(FontStyles style)

Parameters

style FontStyles

Returns

GlyphFormat

WithStyle(int)

Returns a new GlyphFormat with the specified numeric style index, if supported. Otherwise returns the original format unchanged.

public GlyphFormat WithStyle(int style)

Parameters

style int

Returns

GlyphFormat