Gorgon
Show / Hide Table of Contents

Class GorgonGlyph

A glyph used to define a character in a GorgonFont.

Inheritance
object
GorgonGlyph
Implements
IGorgonNamedObject
IEquatable<GorgonGlyph>
Inherited Members
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Fonts
Assembly: Gorgon.Graphics.Fonts.dll
Syntax
public sealed class GorgonGlyph : IGorgonNamedObject, IEquatable<GorgonGlyph>

Properties

| Edit this page View Source

Advance

Property to set or return the horizontal advance for the glyph.

Declaration
public int Advance { get; set; }
Property Value
Type Description
int
Remarks

This value defines the exact width of the glyph and is a total of the left bearing (A), black box width (B), and right bearing (C) for a glyph.

| Edit this page View Source

Character

Property to return the character that this glyph represents.

Declaration
public char Character { get; }
Property Value
Type Description
char
| Edit this page View Source

GlyphCoordinates

Property to return the coordinates, in pixel space, of the glyph.

Declaration
public Rectangle GlyphCoordinates { get; }
Property Value
Type Description
Rectangle
| Edit this page View Source

Offset

Property to set or return the offset of the glyph.

Declaration
public Point Offset { get; set; }
Property Value
Type Description
Point
Remarks

The offset of a glyph is the distance from the glyph black box (i.e. the bounds of the glyph pixels) to the actual starting point of the glyph. For example, if 'g' has an offset of 4, 6 and we change the offset to 3, 4 then the 'g' glyph will be shifted left by 1 pixel and up by 2 pixels when rendering.

| Edit this page View Source

OutlineCoordinates

Property to return the coordinates, in pixel space, of the glyph outline (if applicable).

Declaration
public Rectangle OutlineCoordinates { get; }
Property Value
Type Description
Rectangle
Remarks

This property will only be assigned if a GorgonFont has an outline.

| Edit this page View Source

OutlineOffset

Property to set or return the offset of the glyph outline (if applicable).

Declaration
public Point OutlineOffset { get; set; }
Property Value
Type Description
Point
Remarks

The offset of a glyph is the distance from the glyph outline black box (i.e. the bounds of the glyph pixels) to the actual starting point of the glyph outline. For example, if 'g' has an offset of 4, 6 and we change the offset to 3, 4 then the 'g' glyph outline will be shifted left by 1 pixel and up by 2 pixels when rendering.

This property will only be assigned if a GorgonFont has an outline.

| Edit this page View Source

OutlineTextureCoordinates

Property to return the texture coordinates for the glyph outline (if applicable).

Declaration
public RectangleF OutlineTextureCoordinates { get; }
Property Value
Type Description
RectangleF
Remarks

This property will only be assigned if a GorgonFont has an outline.

| Edit this page View Source

TextureCoordinates

Property to return the texture coordinates for the glyph.

Declaration
public RectangleF TextureCoordinates { get; }
Property Value
Type Description
RectangleF
| Edit this page View Source

TextureIndex

Property to return the array index for the backing texture array.

Declaration
public int TextureIndex { get; }
Property Value
Type Description
int
| Edit this page View Source

TextureView

Property to return the texture that the glyph can be found on.

Declaration
public GorgonTexture2DView TextureView { get; }
Property Value
Type Description
GorgonTexture2DView

Methods

| Edit this page View Source

Equals(GorgonGlyph)

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

Declaration
public bool Equals(GorgonGlyph other)
Parameters
Type Name Description
GorgonGlyph other

An object to compare with this object.

Returns
Type Description
bool

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

| Edit this page View Source

Equals(object)

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

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

An object to compare with this object.

Returns
Type Description
bool

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

Overrides
object.Equals(object)
| Edit this page View Source

GetHashCode()

Returns a hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Overrides
object.GetHashCode()
| Edit this page View Source

ToString()

Returns a string that represents this instance.

Declaration
public override string ToString()
Returns
Type Description
string

A string that represents this instance.

Overrides
object.ToString()
| Edit this page View Source

UpdateTexture(GorgonTexture2D, Rectangle, Rectangle, int)

Function to change the texture pointed at by this glyph.

Declaration
public void UpdateTexture(GorgonTexture2D texture, Rectangle glyphCoordinates, Rectangle outlineCoordinates, int textureArrayIndex)
Parameters
Type Name Description
GorgonTexture2D texture

The texture to assign to the glyph.

Rectangle glyphCoordinates

The coordinates of the glyph on the texture, in pixels.

Rectangle outlineCoordinates

The coordinates of the glyph outline on the texture, in pixels.

int textureArrayIndex

The array index on the 2D texture array to use for this glyph.

Remarks

This allows an application to point a glyph at a new GorgonTexture2D for custom bitmap glyphs, or allows the region on the texture that contains the glyph to be modified. This allows applications to create custom characters in fonts that the font generation code cannot produce.

Currently any custom texture/coordinates are not persisted when the font is saved. This may change in a future release of Gorgon.

If the GorgonFont for this glyph does not have an outline, then the outlineCoordinates should be set to empty.

Exceptions
Type Condition
ArgumentNullException

Thrown when the texture parameter is null.

ArgumentEmptyException

Thrown when the texture is not a 2D texture.

-or-

Thrown if the texture format is not R8G8B8A8_UNorm, R8G8B8A8_UNorm_SRgb, B8G8R8A8_UNorm or B8G8R8A8_UNorm_SRgb.

Implements

IGorgonNamedObject
IEquatable<T>

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author