SharpText.Veldrid 0.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpText.Veldrid --version 0.1.5
NuGet\Install-Package SharpText.Veldrid -Version 0.1.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpText.Veldrid" Version="0.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpText.Veldrid --version 0.1.5
#r "nuget: SharpText.Veldrid, 0.1.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SharpText.Veldrid as a Cake Addin
#addin nuget:?package=SharpText.Veldrid&version=0.1.5

// Install SharpText.Veldrid as a Cake Tool
#tool nuget:?package=SharpText.Veldrid&version=0.1.5

SharpText

Disclaimer: This project is a work in progress and will most likely have bugs (but it does seem to work OK from my experiences so far). Feel free to give it a go and please raise any bugs or feature requests as an issue on this repo. I would be more than happy to look at any PRs for such improvements.

Description

This is a GPU accelerated text renderer implemented in C#. It implements the excellent technique discussed by Evan Wallace here (thanks to Evan for explaining in detail how the technique works and providing example code 😃 ). It comprises of a few steps:

  1. Read in a font file in any supported format (I chose the Typography library as it has .NET Standard support)
  2. Convert the lines and Bezier curves into a set of triangles that can be rendered
  3. Render the triangles out to a render target
  4. Run another pass with the render target as input which renders the final text and performs sub-pixel anti-aliasing

It should reusable across rendering platforms as I have seperated out any platform/implementation specific code into different projects.

At the moment, the project structure looks like this:

  • SharpText.Core - contains shared logic and platform independant code
  • SharpText.Veldrid - implements an ITextRenderer for the Veldrid graphics backend
  • SharpText.DemoApp - a simple demo app to show how to use this library (take a look at Program.cs to get started)

Getting Started

First you will need to create a Font object for the font and size you wish to use.

var font = new Font("Fonts/OpenSans-Regular.woff", 20);

Next you need to create a text renderer using an implementation of ITextRenderer.

This example uses the Veldrid renderer. You need to pass in the GraphicsDevice and CommandList you would like to use, and then the font object we just created.

var textRenderer = new VeldridTextRenderer(graphicsDevice, commandList, font);

Now you can start drawing text with this renderer. This statement will draw the string at position X=5,Y=5 in the color Black.

textRenderer.DrawText("The quick brown fox jumps over the lazy dog", new Vector2(5, 5), new Color(0, 0, 0, 1));

Now just call the Draw method as part of your normal draw loop while you have an active CommandList.

textRenderer.Draw();

Examples

The Demo App Using Open Sans

Demo App Screenshot

Using Amatic SC

Font

Using LeArchitect

Font

Using Sacramento

Font

Using Neon2

Font

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.1 938 3/14/2022
0.2.0 496 1/17/2021
0.1.12 554 5/26/2020
0.1.11 599 1/31/2020
0.1.10 657 1/19/2020
0.1.9 489 1/18/2020
0.1.8 513 1/18/2020
0.1.7 538 1/18/2020
0.1.6 556 1/18/2020
0.1.5 566 1/18/2020