Aurigma Graphics Mill 5.5 for .NET
Overview of Text Drawing
Text rendering is a very important task applied to various types of software. Graphics Mill for .NET implements this functionality and provides a lot of adjustments to display the desired text. Using Graphics Mill for .NET 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 it requires additional steps described in the Drawing Text on a CMYK Bitmap article.
Graphics Mill for .NET provides the possibility to make your text more attractive by applying some effects: shadow, glow, 3D, etc. See the Drawing Text with Effects topic for detailed information and samples on how to draw text with such effects. One more way to make your text eye-catching is to outline it using any approach described in the Drawing Text with Outline article.
To draw text with Graphics Mill for .NET you will need to use the Font and GdiGraphics classes. Let us consider them more detailed.
The Font Class
This class provides an access to font and text rendering settings. They include:
- Name and Size properties to specify typeface name of the font and its size;
- Bold, Italic, Underline, and Strikeout properties to highlight the text;
- Antialiased property to make the text smooth;
- HorizontalAlignment and VerticalAlignment properties to specify how to locate text relative to the drawing coordinates.
The Font class also implements functionality to retrieve font metrics, and other font-related information. For example:
- If you need to get a rectangle the multiline text with given settings will occupy you can use this class as it is described in the Measuring Text Size article.
- To get individual positions of each character in the single-line text, you can use GetCharacterPositions(String, Single) method. See the detailed information on it in the Measuring Characters Positions topic.
- If you need more advanced calculations, this class provides you with a number of font metrics described in the Text Coordinates and Font Metrics article.
There are two ways to set a font in Graphics Mill for .NET. The first way is to specify 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 the 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. So this way can be suitable to raster text layers extracted from PSD files using Advanced PSD Add-on.
The GdiGraphics Class
This class represents drawing functionality provided by Graphics Mill for .NET. It implements three overloaded methods to draw a text:
- DrawString methods draw single-line and outlined text. See Drawing Text String article to obtain the details on how to draw text using this method.
- DrawText methods draw single-style multiline text. The Drawing Multiline Text article contains the detailed information about multiline text drawing.
- DrawFormattedText methods provide a possibility to render multi-style text. It means that text can include portions rendered using different font settings. To specify style for each portion text should be marked up using certain rules. These rules are completely described in the Drawing Formatted Text article.