Drawing Bytes on an Image

Viewed 756

I am trying to get certain bytes to write on an Image, for example:

" །༉ᵒᵗᵗ͟ᵋༀ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟. . . "

When I display it on an image but I am getting the following instead...

Image:

enter image description here

I have tried changing the Encoding Type of the string, when I receive the bytes and there is no set font but I have tried all default Microsoft fonts as well as a few custom ones I found on the Internet. What am I doing Wrong?


Edit: The original was using Graphics.DrawString. I have tried TextRenderer and it came out with almost the same results.

Image:

http://i.stack.imgur.com/kxhyU.jpg

This is the code I'm using to generate the image:

string text = "[rotten4pple]  །༉ᵒᵗᵗ͟ᵋༀ  ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟ ͟. . .";

var font = new Font("Arial", 8, FontStyle.Regular);
var bitmap = new Bitmap(1, 1);
var size = Graphics.FromImage(bitmap).MeasureString(text, font);
bitmap = new Bitmap((int)size.Width + 4, (int)size.Height + 4);
using (var gfx = Graphics.FromImage(bitmap))
{
    gfx.Clear(Color.White);
    TextRenderer.DrawText(gfx, cmd.AllArguments, font, new Point(2, 2),
        Color.Black, Color.White);
}

The variable cmd.AllArguments is passed down into the method, I believe the string is Encoded using windows-1252.

1 Answers
Related