Search code examples
c#.netunicodefontszalgo

How to render Zalgo text in C#


GDI+'s DrawString can't seem to render Unicode superscripts and/or subscripts. It shows them as squares and doesn't stack.

Drawn using DrawString

drawn by GDI

private void Form1_Paint(object sender, PaintEventArgs e)
{
    String text = "ă̡͈̘̠͕̺̯̖̤̺͇̫̗͓̗̤̩̜̩̯̝ͥͪ̍ͯͥ͒ͫ͛ͮ̿ͥ͛́́̈͒ͯ͊̇̿ͪ̓́̋ͨ̌͗̀̾̃ͧ̋͗ͣͦ̑̈̆̚҉̶̸̶̶̷̷̶̸̨̧̧̨̛̛̕͘͘̕͘͜͟͜͜͡͞͠͠͠͏̴̷̴̡̢̀͟͝͠s̸̢̨̥͚̲̝̝̗̤͇͓̫̝͍̥͓̳͕̰̰̙͖̅̾ͨ͗̈́͌̽̋̇ͦ̃͌͌͌̎̃̒̂̆̌ͤ͗̌͂̿̃̋̈́ͦ͂͋͂̽ͪͣ͂ͩ̓̈͆̀͢͜͟͡͠͠͝҉̶̶̧̨̡̧̧̛́́́́̀͘͘̕͢͜͢͢͠͞͠҉́̕͢͝d̵̴̡̡̢̛͙̞̭̲̺̖̯̳̙̞͇͓̖͙̩̩̗̝̮̉̿ͦ͒̓̑̉ͫ̇͒̓̎ͨ̎ͪ̂ͨͨ̿͛͊͛͛͂͐ͭ̄͑̔̄̋̆ͪ̀ͫ͌̉̍́̚̚͘͘͘͟͢͢͞͠͠ͅ҉̴̷̶̶̸̧̢̧̡̢̧̨̛̕͘͘͘͘͘͢͟͡҉f̸̶̵̤̮͚͔̟̮̗̺͖͉̪͔̫͎͓̱̟̰̹̩̈̊ͮͦͯ̅̊ͨ́͊̔ͪ̐ͤ͌̑͋̈́̐͆ͦ̿͌̐̓͐̌͂̅ͩ̄͊͐ͨ̄̄̈́̆̚̚͜͏͏̵̸̧̧̛̛͞͡͡͏̡͘͟͠͏̸̶͏͟͡͞͏̸̡͝͏͠͞͏̴͡͏̢͝";
    e.Graphics.DrawString(text, new Font("Arial Unicode MS", 12), Brushes.Black, 30, 30);
}

Drawn using TextRenderer

Drawn by TextRendere.DrawText

TextRenderer.DrawText(e.Graphics, text, new Font("Arial Unicode MS", 12), new Point(30, 30), Color.Black);

Drawn by firefox

enter image description here

How did FireFox manage to draw this properly?

The data I'm using - http://pastebin.com/p5Cp3qUM


Solution

  • Try calling TextRenderer.DrawText instead.