Render Text with TrueType and Type1 Fonts using C#

render text using fonts

In the previous post, you have seen how to use Aspose.Font for .NET API for loading and saving CFF, TrueType, and Type1 fonts programmatically. In this article, you will learn how to render text with TrueType and Type1 font using C#. The code samples will show you how to generate a JPG image based on the provided text.

.NET Font Rendering API – Installation

Aspose.Font for .NET provides a powerful font rendering mechanism in order to render the text using TrueType and Type1 fonts. You can download the API or get it installed using NuGet.

PM> Install-Package Aspose.Font

Implement Text Rendering Interface

In order to achieve the text rendering, Aspose.Font for .NET provides an IGlyphOutlinePainter interface to draw the glyphs. The following steps demonstrate how to implement the methods in IGlyphOutlinePainter.

  • Define a utility method to calculate the font’s width according to the image’s width.

Render Text with TrueType Font using C#

The following code sample shows how to use the above-mentioned implementation to render text with a TrueType font using C#.

Render Text with Type1 Font using C#

The following code sample shows how to render text with a Type1 font using C#.

Conclusion

In this article, you have learned how to implement the rendering of text with a TrueType or Type1 font using C#. The code samples have shown how to generate JPG images based on the provided text. You can explore more about Aspose.Font for .NET using the documentation.

See Also