Working with Text and Fonts

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.

  1. Instantiate a Bitmap object
  2. Instantiate a Graphics object with the bitmap object
  3. Initialize a brush
  4. Use the DrawString method to draw text on the bitmap

Draw text

Format Text

In order to format text using C#, the following steps can be used.

  1. Instantiate a Bitmap object
  2. Instantiate a Graphics object with the bitmap object
  3. Define the necessary string format parameters such as string alignment and line alignment
  4. Use the DrawString method to draw formatted text

Format text

Text Hinting

Text hinting mode can be specified using the API. The following C# code shows how to set the grid fitting mode.

  1. Instantiate a Bitmap object
  2. Instantiate a Graphics object with the bitmap object
  3. Use the TextRenderingHint property of the Graphics object to specify the hinting mode
  4. Use the DrawText method to draw text with the defined mode

Text hinting

Installed Fonts

Installed fonts