Font 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)


public sealed class Font : IDisposable


You can use this class for two intentions.

  1. Specifying text rendering parameters. These settings are used to draw the text. 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. Text measurement. 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.

If you need to know how much room a text string with given settings will occupy use the MeasureString(String, Font) method.


using (var bitmap = new Bitmap(300, 30, PixelFormat.Format24bppRgb, RgbColor.White))
    using (var graphics = bitmap.GetGraphics())
        //Draw text
        var font = new Font("Futura Md BT", 20);
        font.Bold = false;
        font.Italic = true;
        font.Underline = true;
        font.Strikeout = false;
        font.HorizontalAlignment = HorizontalAlignment.Center;

        var brush = new SolidBrush(RgbColor.Red);

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


Inheritance Hierarchy

L Aurigma.GraphicsMill.Drawing.Font

Thread Safety

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

See Also