Skip to content

IFont Interface

Represents a font used by the rendering engine.

C#
public interface IFont : IDisposable

The name of the font used when it is registered with the Fonts collection.

C#
string Name { get; }

The height of each glyph in pixels.

C#
int GlyphHeight { get; }

The width of each glyph in pixels.

C#
int GlyphWidth { get; }

The amount of pixels between glyphs.

C#
int GlyphPadding { get; set; }

Gets how many glyphs this font has.

C#
int TotalGlyphs { get; }

Which glyph index is considered completely solid white. Used for shading.

C#
int SolidGlyphIndex { get; set; }

The rectangle to draw the solid glyph used for shading.

C#
Rectangle SolidGlyphRectangle { get; }

The glyph index to use when an unsupported glyph is used during rendering.

C#
int UnsupportedGlyphIndex { get; set; }

The rectangle to draw when a glyph that isn’t supported is used by a surface.

C#
Rectangle UnsupportedGlyphRectangle { get; }

True when the font supports SadConsole extended decorators; otherwise false.

C#
bool IsSadExtended { get; set; }

The texture used by the font.

C#
ITexture Image { get; set; }

A dictionary that stores the source rectangles of the font by glyph id.

C#
Dictionary<int, Rectangle> GlyphRectangles { get; }

A collection of named glyph definitions.

C#
Dictionary<string, GlyphDefinition> GlyphDefinitions { get; }

Gets the registered rendering rectangle for a glyph.

C#
Rectangle GetGlyphSourceRectangle(int glyph)

glyph int
The index of the glyph to get.

SadRogue.Primitives.Rectangle
The rectangle for the glyph.

Generates a rectangle for the specified glyph. For the actual font rectangle, use GetGlyphSourceRectangle(int).

C#
Rectangle GenerateGlyphSourceRectangle(int glyph)

glyph int
The glyph.

SadRogue.Primitives.Rectangle
A rectangle based on where the font thinks the rectangle should be.

Gets the pixel size of a font based on a IFont.Sizes.

C#
Point GetFontSize(IFont.Sizes size)

size IFont.Sizes
The desired size.

SadRogue.Primitives.Point
The width and height of a font cell.

Gets a CellDecorator by the GlyphDefinition defined by the font file.

C#
CellDecorator GetDecorator(string name, Color color)

name string
The name of the decorator to get.

color SadRogue.Primitives.Color
The color to apply to the decorator.

CellDecorator
The decorator instance.

If the decorator does not exist, Empty is returned.

Returns true when the glyph has been defined by name.

C#
bool HasGlyphDefinition(string name)

name string
The name of the glyph

bool
true when the glyph name exists, otherwise false.

Gets a GlyphDefinition by name that is defined by the font file.

C#
GlyphDefinition GetGlyphDefinition(string name)

name string
The name of the glyph definition.

GlyphDefinition
The glyph definition.

If the glyph definition doesn’t exist, return sEmpty.