Supporting Thai language

Thai have two challenges:

  1. Vowel marks will not be placed correctly
  2. The language has words but no spaces, which will mess up line breaks.

Vowel marks
The s-shaped glyphs above characters are not handled by the framework and will always end up one character to the right of were it should be.

I manage to hack the framework to move the carriage back on the marks.

  • This is probably not recommended, but I have done a lot of testing and it runs fine so far.
  • I have used AI assisted programming.

Line breaks
There is a couple of solutions to this, I use AI to put “|“ between each word and then replace it with a zero length space (don’t forget to update your line break).

//English
public override string Help_Work_Automatic => “The work is automatic”;

//Thai
public override string Help_Work_Automatic => TextLib.ThaiConv(“การ|ทำ|งาน|เป็น|ไป|โดย|อัตโนมัติ”);

public const char ZeroWidthSpaceChar = ‘\u200B’;
public static string ThaiConv(string text)
{
return text.Replace(‘|’, ZeroWidthSpaceChar);
}

Tip 1
Thai characters are more detailed and need to be about 20% larger than English.

Tip 2
Here is my font setup that covered all text so far:

<FontName>Leelawadee UI</FontName>

<Size>30</Size>
<Spacing>0</Spacing>
<UseKerning>true</UseKerning>
<Style>Regular</Style>

<CharacterRegions>

	<CharacterRegion>
		<Start>&#32;</Start>
		<End>&#126;</End>
	</CharacterRegion>

	<CharacterRegion>
		<Start>&#x0E00;</Start>
		<End>&#x0E7F;</End>
	</CharacterRegion>

	<CharacterRegion>
		<Start>&#x200B;</Start>
		<End>&#x200B;</End>
	</CharacterRegion>

	<CharacterRegion>
		<Start>&#x4E00;</Start>
		<End>&#x9FFF;</End>
	</CharacterRegion>

	<CharacterRegion>
		<Start>&#x3000;</Start>
		<End>&#x303F;</End>
	</CharacterRegion>
	<CharacterRegion>
		<Start>&#xFF00;</Start>
		<End>&#xFFEF;</End>
	</CharacterRegion>

</CharacterRegions>