This documentation is for the old version. Go to the latest Graphics Mill docs

Font Class

This class accumulates font and other text rendering settings. It also provides functionality for retrieving font metrics, and other font-related information.

Namespace: Aurigma.GraphicsMill.Drawing
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Class Font _
	Inherits UnitConverterObject _
	Implements ICloneable
C#
public class Font : UnitConverterObject, ICloneable

Remarks

You can use this class for two intentions.
  1. First of all, you can set text rendering parameters here. These settings are used to draw the text or on window. This way you can specify font Name, Size, make it Bold, Italic, Underline, Strikeout, etc. You can also adjust text rendering quality by using Antialiased property. Using HorizontalAlignment and VerticalAlignment properties you specify how to locate text relatively drawing coordinates.
  2. Another application of this class is to accomplish text measurement. It is often important to know how much room text string with given settings will occupy. Method MeasureString(String) provides easy way to do it. Just fill necessary properties, and this method returns width and height of the text. If you need to know individual positions of each character in the text string, you can use GetCharacterPositions(String, Single) method. If you need more advanced calculations, this class provides you a number of font metrics, like Ascent, Descent, AverageCharWidth, ExternalLeading, InternalLeading, and others.

All space values (like font metrics, font size, etc) are returned in units specified with Unit property.

Examples

Visual Basic
Dim bitmap As New Aurigma.GraphicsMill.Bitmap( _
 Aurigma.GraphicsMill.RgbColor.White, 300, 30, _
 Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmap.GetGdiGraphics

'Draw text
Dim font As New Aurigma.GraphicsMill.Drawing.Font("Futura Md BT", 20)
font.Bold = False
font.Italic = True
font.Underline = True
font.Strikeout = False
font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Center

Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush( _
 Aurigma.GraphicsMill.RgbColor.Red)

graphics.DrawString("Sample text", font, brush, 150, 0)
C#
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(
    Aurigma.GraphicsMill.RgbColor.White, 300, 30, 
    Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

Aurigma.GraphicsMill.Drawing.GdiGraphics graphics = bitmap.GetGdiGraphics();

//Draw text
Aurigma.GraphicsMill.Drawing.Font font = 
    new Aurigma.GraphicsMill.Drawing.Font("Futura Md BT", 20);
font.Bold = false;
font.Italic = true;
font.Underline = true;
font.Strikeout = false;
font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Center;

Aurigma.GraphicsMill.Drawing.SolidBrush brush = 
    new Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Red);

graphics.DrawString("Sample text", font, brush, 150, 0);

Inheritance Hierarchy

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model





See Also

Reference