Drawing Text and Fonts with Java

Working with text and fonts using Java is simplified with Aspose.Drawing for Java. You can effortlessly combine fonts and text styles to draw text during graphics drawing. This article guides you on:

  • Drawing Text
  • Formatting Text
  • Text Hinting
  • Retrieving Existing Fonts

Draw Text in Java

Below are the steps to draw text:

These simple steps empower you to effortlessly integrate text into your graphics using Aspose.Drawing for Java.

Draw text

Format Text in Java

Formatting text adds a layer of sophistication to your Java graphics, and with Aspose.Drawing for Java, it’s a straightforward process. Here’s how you can format text:

  • Begin by creating a Bitmap object.
  • Initialize a new Graphics object using the created bitmap object.
  • Specify the necessary string format parameters, such as string alignment and line alignment, to achieve the desired formatting.
  • Utilize the drawString() method to effortlessly draw formatted text on the bitmap.

Format text

Text Hinting in Java

Text hinting mode is a crucial aspect of text rendering, and with Aspose.Drawing for Java, you have the flexibility to control it. Steps to Set Text Hinting Mode:

  • Start by creating a Bitmap object.
  • Initialize a new Graphics object using the created bitmap object.
  • Utilize the TextRenderingHint property of the Graphics object to specify the desired hinting mode.
  • Finally, employ the drawText function to draw text with the specified hinting mode.

By following these steps, you can precisely control the text hinting mode to achieve optimal text rendering using Aspose.Drawing for Java.

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

Text hinting

Installed Fonts in Java

Retrieving Existing Fonts in Java:

Installed fonts