Render Text with TrueType and Type1 Fonts in C# | C# Font API

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.

C# Font API to Render Text

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#.

C# Font API - Learning Resources

Beides rendering text using TTF or Type1 fonts, explore various other features of Aspose.Font for .NET using the resources below:

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. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also