NvgSharp uses FontStashSharp for the text rendering.
Fonts should be initialized outside of the NvgSharp, using FontStashSharp API.
I.e. following code creates FontSystem from a ttf:
FontSystem fontSystem = new FontSystem(); fontSystem.AddFont(File.ReadAllBytes(@"Fonts/DroidSans.ttf"));
Now you can use that FontSystem to render text in the NvgSharp:
SpriteFontBase font = fontSystem.GetFont(18); // 18 is font size(line height in pixels) _nvgContext.Text(font, "Hello, World!", 100, 100);
Original nanovg has additional align parameters for the text rendering method. Copy following code if you want those parameters in the NvgSharp: https://github.com/rds1983/NvgSharp/blob/master/samples/NvgSharp.Samples.Demo/NvgExtensions.cs
There was an error while loading. Please reload this page.