Vixen
02b45cc4
csharp
public static class DebugFont

A stroke font: every glyph is a handful of line segments, so text costs nothing but the pipeline that is already drawing debug geometry.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Why a font like this exists at all, next to a real text stack. Vixen.Ui.Text shapes, wraps and rasterises properly, and everything the user is meant to read goes through it. Debug text is the one place where that is the wrong dependency: it has to work in a build with no atlas uploaded, no font asset resident and no UI document — the frame where the asset system is the thing being debugged — and it has to come out of the same draw call as the lines it labels. A table of strokes has no assets, no atlas and no upload; it is the same vertex buffer as everything else here.

Deliberately not a text renderer. There is no kerning, no shaping, no bidi and no script beyond ASCII: anything outside 32–126 is drawn as a box, which is the honest rendering of "this font cannot show you that" and is what a diagnostic overlay should do rather than silently dropping the character.

Text space has y pointing down and its origin at the top-left of the first glyph's cap box, because that is what a screen-space overlay wants and what every layout in this engine already means by a position. World-space text flips it once, in the renderer, where the camera basis is known.

Fields and properties (7)

  • public const int GridWidth

    How wide a glyph's cell is, in grid units.

  • public const int GridBaseline

    Which grid row the baseline sits on.

  • public const int GridTop

    Which grid row a capital's top sits on.

  • public const int GridAdvance

    How far one glyph moves the pen, in grid units — the cell plus its gap.

  • public const int GridCapHeight

    How tall a capital is, in grid units. The unit size is measured in.

  • public const char FirstCharacter

    The first character the table covers.

  • public const char LastCharacter

    The last character the table covers.

Methods (6)

  • public static float AdvanceFor(float size)

    How far one character moves the pen, for text of this height.

  • public static float LineHeightFor(float size)

    How far apart two lines of text sit, for text of this height.

  • public static float MeasureWidth(ReadOnlySpan<char> text, float size)

    How wide a string draws — the widest of its lines, if it has several.

  • public static float MeasureHeight(ReadOnlySpan<char> text, float size)

    How tall a string draws, counting every line.

  • public static int SegmentCount(ReadOnlySpan<char> text)

    How many segments a string draws, so a caller can reserve exactly the room it needs.

  • public static void Emit<TSink>(ReadOnlySpan<char> text, Vector2 origin, float size, ref TSink sink) where TSink : IDebugFontSink

    Draws a string into a sink, one segment at a time.

Used by (9)

  • ConsoleOverlayVixen.Engine
  • DebugDrawVixen.Engine
  • DebugDrawShapeTestsVixen.Engine.Tests
  • DebugFontTestsVixen.Engine.Tests
  • DebugGeometryVixen.Engine.Renderer
  • DebugGeometryTestsVixen.Engine.Renderer.Tests
  • LogOverlayVixen.Engine
  • OverlayRegionVixen.Engine
  • OverlaySurfaceVixen.Engine