Drawing Text API

Warning

This section describes the drawing text API that is out of date. If you want to learn about text API represented by the new drawing engine in Graphics Mill, read the Drawing Text article.

Text rendering is a very important task applied to various types of software. Graphics Mill implements this functionality and provides a lot of adjustments that display the desired text. Using Graphics Mill you can draw both single-line and multiline text on RGB, indexed, or grayscale images. It is also possible to draw text on a CMYK bitmap but this requires additional steps.

Note

When you try to draw text on a grayscale bitmap, you will notice that the text is not antialiased. The problem is that neither GDI nor GDI+ supports grayscale bitmaps, therefore Graphics Mill has to imitate it as indexed bitmap with the grayscale palette. However, antialiasing is impossible on indexed bitmaps.

Graphics Mill provides for the possibility to make your text more attractive by applying some effects: shadow, 3D, etc. One more way to make your text eye-catching is to outline it.

To draw text with Graphics Mill you will need to use the Font and Graphics classes. We will now consider them both in more detail.

The Font Class

This class provides access to the font and text rendering settings. They include:

The Font class also implements functionality to retrieve font metrics, and other font-related information. For example:

There are two ways to set a font in Graphics Mill. The first way is to specify a font family name, size, and boolean values indicating whether the rendered text is bold, italic, underlined, and so on. The second way is to use a PostScript name of the font installed on a computer. To apply the first one you can use any constructor of the Font class. The second one can be applied using the Font.CreateSpecificFont(String, Boolean, Single) static method which returns the font with the requested name. The PostScript format is commonly used in Adobe applications. Therefore this method is suitable to raster text layers extracted from PSD files.

The Graphics Class

This class represents drawing functionality provided by Graphics Mill. It implements three overloaded methods to draw text:

  • DrawString methods draw single-line and outlined text. See the Simple Text String article to obtain the details on how to draw text using this method.
  • DrawText methods draw single-style multiline text.
  • DrawFormattedText methods provide the ability to render multi-style text. This means that text can include portions rendered using different font settings. To specify the style for each portion, the text should be marked up using rules.