Subscript and Superscript

Text Formatted Text

Draws subscript and superscript text.

Сode Snippet

// Here one may find all possible tags
// https://www.graphicsmill.com/docs/gm/advanced-formatted-text.htm

using (var bitmap = new Bitmap(200, 200, PixelFormat.Format24bppRgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    var text = new PlainText("X<span style='sup:true;sup-position:0.333;sup-size:0.583'>2</span>\nX<span style='sub:true;sub-position:0.333;sub-size:0.583'>2</span>", gr.CreateFont("Verdana", 50))
    {
        Position = new System.Drawing.PointF(30, 80),
    };

    gr.DrawText(text);

    bitmap.Save("SubscriptSuperscript.png");
}

Output

SubscriptSuperscript.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog