Working with Text and Fonts
Contents
[
Hide
]
Working with text and fonts using C# is easy with Aspose.Drawing for .NET. You can combine fonts and text styles to draw text during graphics drawing. This article shows how to:
- Format Text
- Draw Text
- Get Existing Fonts
- Use Text Hinting
Draw Text
In order to draw text using C#, the following steps can be used.
- Instantiate a Bitmap object
- Instantiate a Graphics object with the bitmap object
- Initialize a brush
- Use the DrawString method to draw text on the bitmap
Format Text
In order to format text using C#, the following steps can be used.
- Instantiate a Bitmap object
- Instantiate a Graphics object with the bitmap object
- Define the necessary string format parameters such as string alignment and line alignment
- Use the DrawString method to draw formatted text
Text Hinting
Text hinting mode can be specified using the API. The following C# code shows how to set the grid fitting mode.
- Instantiate a Bitmap object
- Instantiate a Graphics object with the bitmap object
- Use the TextRenderingHint property of the Graphics object to specify the hinting mode
- Use the DrawText method to draw text with the defined mode