Font.VerticalAlignment Property

Gets or sets a vertical text alignment.

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

Syntax

C#
public VerticalAlignment VerticalAlignment { get; set; }

Property Value

A VerticalAlignment value. The default value is Top.

Remarks

Vertical text alignment is a value specifying how to locate the text string relatively to an Y-coordinate of the output point (which is defined in the DrawString(String, Font, Pen, Brush, Int32, Int32) method).

Examples

C#
using (var bitmap = new Bitmap(200, 60, PixelFormat.Format24bppRgb, RgbColor.White))
{
    using (var graphics = bitmap.GetGraphics())
    {
        var pen = new Pen(RgbColor.Red, 1);
        graphics.DrawLine(pen, 0, 30, 200, 30);

        var brush = new SolidBrush(RgbColor.Black);

        //Adjust font settings
        var font = new Font("Arial", 20, false, false);
        font.HorizontalAlignment = HorizontalAlignment.Left;

        //Draw text with different vertical alignments            
        font.VerticalAlignment = VerticalAlignment.Bottom;
        graphics.DrawString("Bottom", font, brush, 0, 30);

        font.VerticalAlignment = VerticalAlignment.Baseline;
        graphics.DrawString("Baseline", font, brush, 80, 30);

        font.VerticalAlignment = VerticalAlignment.Top;
        graphics.DrawString("Top", font, brush, 160, 30);

        bitmap.Save(@"Images\Output\string.png");
    }
}

See Also

Reference