Get the correct graphical representation of Thai combination characters

522 views Asked by At

I'm trying to write a bitmap font that can render Thai (amongst others). I've got the character set but a lot of the characters are "combining character" codepoints. I'm using Graphics.DrawString to get a bitmap of the characters. This worked fine for e.g. Latin, Cyrillic and Vietnamese.

However, when I render a singled-out combining character, Windows .Net renders a dotted circle beneath the combining character like so:thai characters

Is there a way to remove those circles? (They are not always in the same place)

This is the code I'm using now:

string face = "Arial";
Font chosenFont = new Font(face, GetFontSize(), fontStyle));
string str = " " + Char.ConvertFromUtf32(c) + " ";
UnsafeBitmap32 bmp = new UnsafeBitmap32(width, height);
Graphics gfx = Graphics.FromImage(bmp.Bitmap);
gfx.FillRectangle(Brushes.Black, 0, 0, width, height);
gfx.DrawString(str, chosenFont, Brushes.White, posX, posY);
1

There are 1 answers

0
koan On

As you have discovered in the comments to your question, it does not make sense to render a combining character or NSM without at least a consonant in the current character cell.

Therefore you cannot render these characters alone as in the font and font renderer the positioning is dependent on the preceding characters.

You may get lucky and find a font and font renderer that will show the characters you need when combined with a space; but as you have found some systems will render with a circle.

If you are designing a bitmap font then simply cut and paste the area of the glyph. If you are trying to render a vector font and grab the glyph automatically then I doubt you will achieve anything but a hacky solution that won't work with all fonts and font renderers.