Skip to content

GraphicsAPI reference

Class FontExtensions

Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Text.dll
Guide: Graphics

Layout and drawing helpers that work with any IFont.

C#
public static class FontExtensions

Inheritance

object ← FontExtensions

Methods

DrawCentered(IFont, IRenderer, string, Vector2, Color)

Draws text centred on center, rounded to whole pixels.

C#
public static void DrawCentered(this IFont font, IRenderer renderer, string text, Vector2 center, Color color)

Parameters

font IFont

renderer IRenderer

text string

center Vector2

color Color

DrawShadowed(IFont, IRenderer, string, Vector2, Color, Color, Vector2?)

Draws text over a copy of itself in shadow, moved by offset (one pixel down and right by default).

C#
public static void DrawShadowed(this IFont font, IRenderer renderer, string text, Vector2 position, Color color, Color shadow, Vector2? offset = null)

Parameters

font IFont

renderer IRenderer

text string

position Vector2

color Color

shadow Color

offset Vector2?

MeasureWidth(IFont, string)

Width of the widest line of text in canvas pixels.

C#
public static float MeasureWidth(this IFont font, string text)

Parameters

font IFont

text string

Returns

float

Wrap(IFont, string, float)

Greedy word wrap that respects explicit newlines: no line is wider than maxWidth, and a word wider than that on its own is broken between characters.

C#
public static IReadOnlyList<string> Wrap(this IFont font, string text, float maxWidth)

Parameters

font IFont

text string

maxWidth float

Returns

IReadOnlyList<string>