Class LetterMeshFactory
Builds solid, extruded 3D letter and digit meshes from glyph outlines authored in code.
public static class LetterMeshFactory
- Inheritance
-
LetterMeshFactory
Remarks
This exists because Stride exposes no font glyph outlines at runtime, and the libraries that do extract them go through DirectWrite, which is Windows-only - the wrong trade for a cross-platform toolkit. Authoring each glyph as a set of small 2D polygons sidesteps fonts entirely: the outlines here work on every platform Stride runs on, at the cost of supporting only the characters somebody has drawn. See SupportedCharacters for what exists so far.
For ordinary text - labels, HUDs, signs - use EntityTextComponent or
WorldTextComponent instead; they render any string in a real font. This is for lettering
that is meant to be geometry: a title that catches the light, casts a shadow, tumbles
under physics, and takes a material like any other mesh.
A glyph is one or more simple polygons that touch along their edges but never overlap. That is how holes work without hole-aware triangulation: an O is four bars meeting at their corners, an 8 is seven. Abutting pieces render seamlessly because their shared walls end up sealed inside the solid; overlapping pieces would put two caps on the same plane and shimmer, which is why the segment bands below share exact coordinates.
Properties
SupportedCharacters
Gets the characters that have an authored glyph. Space is also accepted and advances without drawing; lookups are case-insensitive.
public static string SupportedCharacters { get; }
Property Value
Methods
CreateTextMeshDraw(GraphicsDevice, string, float, float, bool)
Builds one mesh containing the given text as solid extruded glyphs.
public static MeshDraw CreateTextMeshDraw(GraphicsDevice device, string text, float depth = 0.25, float spacing = 0.15, bool centerOrigin = false)
Parameters
deviceGraphicsDeviceThe graphics device the mesh buffers are created on.
textstringThe text to build. Every character must be in SupportedCharacters, or a space.
depthfloatGlyph depth along Z, in glyph units. Defaults to 0.25.
spacingfloatGap between glyphs, in glyph units. Defaults to 0.15.
centerOriginboolWhen true, the whole string is centred on the entity origin instead of starting at it - which is what a physics body wants, so the collider and the visual share a centre and the mesh tumbles about its middle.
Returns
- MeshDraw
A mesh draw of the whole string, centred on Z = 0. With
centerOriginfalse the baseline is at Y = 0 and the pen starts at X = 0; with it true the string's centre sits on the origin.
Remarks
The caller owns the returned draw's GPU buffers, exactly as with ToMeshDraw(GraphicsDevice, bool).
Exceptions
- ArgumentNullException
The device or text is null.
- ArgumentException
The text is empty, or contains a character with no authored glyph.
TryGetOutlines(char, out Vector2[][])
Returns the authored glyph for a character: one or more simple polygons in a 1-unit-tall box with the pen at the bottom-left.
public static bool TryGetOutlines(char character, out Vector2[][] outlines)
Parameters
charactercharThe character to look up. Case-insensitive.
outlinesVector2[][]The glyph's polygons, each with corners in order.