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
originalGlyphFormat
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
colorColorText color. Defaults to black.
alignmentTextAlignmentText alignment. Defaults to Left.
textSizefloatText size. Defaults to 1.0f ~= 12pts.
styleFontStylesFont style. Defaults to Regular.
fontIFontMinFont 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
colorColorText color. Defaults to black if unspecified.
alignmentTextAlignmentText alignment.
textSizefloatText size normalized to 1.0f ~= 12pts.
fontNamestringName of the font registered in FontManager.
styleFontStylesFont 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
colorColoralignmentTextAlignmenttextSizefloatfontStyleVector2I
Fields
Black
Black text using default font and regular style.
public static readonly GlyphFormat Black
Field Value
Blueish
Light blue-ish text commonly used for highlighted or neutral UI elements.
public static readonly GlyphFormat Blueish
Field Value
Empty
Empty/invalid format. All fields are default/zero.
public static readonly GlyphFormat Empty
Field Value
White
White text using default font and regular style.
public static readonly GlyphFormat White
Field Value
Properties
Alignment
Text alignment for this format (Left, Center, or Right).
public TextAlignment Alignment { get; }
Property Value
Color
The color of the text.
public Color Color { get; }
Property Value
Font
The font used by this format, retrieved from the global FontManager.
public IFontMin Font { get; }
Property Value
FontStyle
The specific style (Regular, Bold, Italic, etc.) applied to the font.
public FontStyles FontStyle { get; }
Property Value
StyleIndex
Combined font index and style index as a Vector2I (X = font index, Y = style index).
public Vector2I StyleIndex { get; }
Property Value
TextSize
Scale multiplier for text size. 1.0f ~= 12pts
public float TextSize { get; }
Property Value
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
formatGlyphFormat
Returns
Equals(object)
Determines whether this format is equal to another object.
public override bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
Returns a hash code for this format.
public override int GetHashCode()
Returns
WithAlignment(TextAlignment)
Returns a new GlyphFormat with the specified alignment.
public GlyphFormat WithAlignment(TextAlignment textAlignment)
Parameters
textAlignmentTextAlignment
Returns
WithColor(Color)
Returns a new GlyphFormat with the specified color.
public GlyphFormat WithColor(Color color)
Parameters
colorColor
Returns
WithFont(IFontMin, FontStyles)
Returns a new GlyphFormat using the specified font and style.
public GlyphFormat WithFont(IFontMin font, FontStyles style = FontStyles.Regular)
Parameters
fontIFontMinstyleFontStyles
Returns
WithFont(int)
Returns a new GlyphFormat using the font at the given index (style unchanged).
public GlyphFormat WithFont(int font)
Parameters
fontint
Returns
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
fontNamestringstyleFontStyles
Returns
WithFont(Vector2I)
Returns a new GlyphFormat using the specified font/style index pair.
public GlyphFormat WithFont(Vector2I fontStyle)
Parameters
fontStyleVector2I
Returns
WithSize(float)
Returns a new GlyphFormat with the specified text size.
public GlyphFormat WithSize(float size)
Parameters
sizefloat
Returns
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
styleFontStyles
Returns
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
styleint