A WIP simple text rendering library for the Veldrid library and .NET Core.
This library is intended more as a tech demo of font rendering using Veldrid than for any serious use in your application. It's only been tested on Windows. Veldrid already supports a full user interface using dear ImGui which I would recommend for your text rendering needs.
TextRender generates text on the CPU using SixLabors libraries (MIT). Text is rendered in an orthographic projection (2D).
Veldrid font texture generation formerly thanks to OpenSAGE TextCache and ResourcePool classes (LGPL-3.0), Currently uses my own implementation.
Shaders are included in the TextRender library as embedded resources. They can be compiled separately using the TextRender.Resources project.
TextRender is available on NuGet:
var textRenderer = new TextRender.TextRenderer(_graphicsDevice);
var text = new Text(textRenderer, "Hello world!")
{
Position = new Vector2(200, 100),
FontSize = 24,
Color = RgbaFloat.White
};
text.Initialize();
text.Draw();
text.Dispose();
textRenderer.Dispose();
var textRenderer = new TextRender.TextRenderer(_graphicsDevice);
var text = new Text(textRenderer, "Hello world!")
{
Position = new Vector2(200, 100),
FontSize = 24,
Color = RgbaFloat.White
};
text.Initialize();
text2 = new Text(textRenderer, "Test")
{
Position = new Vector2(400, 150),
FontSize = 36,
FontStyle = FontStyle.Bold,
FontName = "Courier New",
Color = RgbaFloat.Yellow
};
text2.Initialize();
textRenderer.BeginDraw();
text.DrawBatched();
text2.DrawBatched();
textRenderer.EndDraw();
text.Dispose();
text2.Dispose();
textRenderer.Dispose();