1

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);
Luc Bloom
  • 1,120
  • 12
  • 18
  • You may need to provide with some minimal code example. The problem largely depends on the app type you're creating and runtime environment. Also, make sure to let us know exact versions of fonts you're using on the machine where the app is running. E.g., Arial Unicode may be different depending whether or not Thai is installed. Also, "these circles" are consonant placeholders. An upper/under vowel marks or tone marks have no sense without a consonant. Pls review [some basic info](https://en.wikipedia.org/wiki/Thai_script) about Thai script. – Be Brave Be Like Ukraine Feb 01 '16 at 19:04
  • I'm familiar with the fact that they need to be combined. I'm trying to remove the consonant placeholders so I have a "clean" symbol to combine. I'm beginning to think that it's not possible and that I'll have to either: 1) Render each consonants with each combine (NxM) and write a "precombination replacement" algorithm or 2) Use a library like FreeType2 to gain full TTF support. I think my time is best spent doing the latter. – Luc Bloom Feb 02 '16 at 10:26
  • Thanks for the source code. In addition, is that correct that your `c` is just a single combination character (e.g., MaiEk, MaiTo, etc)? If so, this is an invalid Unicode string. It can display something, but platform implementations may vary. I think, there are two good solutions: (1) Thai-specific: use KoKai consonant (`U+0E01`); (2) International-aware: use `U+25CC` DOTTED CIRCLE. [This article](https://marc.durdin.net/2015/01/how-to-rendering-combining-marks-consistently-across-platforms-a-long-story/) has a great insignt of pro's and con's of each solution. – Be Brave Be Like Ukraine Feb 03 '16 at 12:38

1 Answers1

0

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.

koan
  • 3,596
  • 2
  • 25
  • 35