-
-
Save allfake/d4fde9c573eaa4d5461a07ad446faf18 to your computer and use it in GitHub Desktop.
For Unity 2019 plase use this | |
==> https://github.com/rutcreate/TextMesh-Pro-Thai | |
==> 90% of font need to edit for some character | |
==> or add | |
==> "com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git" | |
==> To manifest.json in your project | |
==> Unity5 or lower | |
Manual Patch | |
Generate Font by range 0-255,688-767,3584-3711,7104-7167,8192-8304,63232-63258 | |
This asset cannot be use https://www.assetstore.unity3d.com/en/#!/content/84126 | |
because this asset don't include source code see http://digitalnativestudios.com/forum/index.php?topic=1471.0. | |
Please contact Stephan B. . | |
แก้สระลอยของภาษาไทยใน asset ที่ชื่อว่า Text Mesh Pro | |
โดยแก้ตามไฟล์ด้านล่าง | |
https://www.assetstore.unity3d.com/en/#!/content/84126 ใช้ไม่ได้เพราะไม่มี source code นาจา | |
ดูได้ตาม link http://digitalnativestudios.com/forum/index.php?topic=1471.0. | |
------ | |
TMPro_uiEditorPanel.cs | |
Add before "private SerializedProperty horizontalMapping_prop;". | |
private SerializedProperty fixThaiVowel_prop; | |
Add before "enableWordWrapping_prop = serializedObject.FindProperty("m_enableWordWrapping");" | |
fixThaiVowel_prop = serializedObject.FindProperty("m_fixThaiVowel"); | |
Add after | |
" | |
// EXTRA PADDING | |
EditorGUI.BeginChangeCheck(); | |
EditorGUILayout.PropertyField(enableExtraPadding_prop, new GUIContent("Extra Padding?")); | |
if (EditorGUI.EndChangeCheck()) | |
{ | |
havePropertiesChanged = true; | |
checkPaddingRequired_prop.boolValue = true; | |
} | |
" | |
EditorGUI.BeginChangeCheck(); | |
EditorGUILayout.PropertyField(fixThaiVowel_prop, new GUIContent("Fix Thai Vowel?")); | |
if (EditorGUI.EndChangeCheck()) | |
{ | |
havePropertiesChanged = true; | |
} | |
------ | |
TMP_EditorPanel.cs | |
Add before "private SerializedProperty enableWordWrapping_prop;". | |
private SerializedProperty fixThaiVowel_prop; | |
Add before "horizontalMapping_prop = serializedObject.FindProperty("m_horizontalMapping");" | |
fixThaiVowel_prop = serializedObject.FindProperty("m_fixThaiVowel"); | |
Add after | |
" | |
// EXTRA PADDING | |
EditorGUI.BeginChangeCheck(); | |
EditorGUILayout.PropertyField(enableExtraPadding_prop, new GUIContent("Extra Padding?")); | |
if (EditorGUI.EndChangeCheck()) | |
{ | |
havePropertiesChanged = true; | |
checkPaddingRequired_prop.boolValue = true; | |
} | |
" | |
// FIX THAI VOWEL | |
EditorGUI.BeginChangeCheck(); | |
EditorGUILayout.PropertyField(fixThaiVowel_prop, new GUIContent("Fix Thai Vowel?")); | |
if (EditorGUI.EndChangeCheck()) | |
{ | |
havePropertiesChanged = true; | |
} | |
------ | |
TMP_Text.cs | |
Add before "protected virtual void LoadFontAsset() { }". | |
[SerializeField] | |
private bool m_fixThaiVowel = true; | |
Add after | |
" | |
switch (m_inputSource) | |
{ | |
case TextInputSources.String: | |
case TextInputSources.Text: | |
StringToCharArray(m_text, ref m_char_buffer); | |
break; | |
case TextInputSources.SetText: | |
SetTextArrayToCharArray(m_input_CharArray, ref m_char_buffer); | |
break; | |
case TextInputSources.SetCharArray: | |
break; | |
} | |
" | |
if (m_fixThaiVowel) | |
{ | |
FixThaiVowel(); | |
} | |
Add Before end. | |
#region Fix Thai Vowel | |
// Lower level characters | |
private const int SARA_U = 3640; | |
private const int SARA_UU = 3641; | |
private const int PHINTHU = 3642; | |
// Lower level characters after pullDown | |
private const int SARA_U_DOWN = 63256; | |
private const int SARA_UU_DOWN = 63257; | |
private const int PHINTHU_DOWN = 63258; | |
// Upper level 1 characters | |
private const int MAI_HAN_AKAT = 3633; | |
private const int SARA_AM = 3635; | |
private const int SARA_I = 3636; | |
private const int SARA_Ii = 3637; | |
private const int SARA_Ue = 3638; | |
private const int SARA_Uee = 3639; | |
private const int MAI_TAI_KHU = 3655; | |
// Upper level 1 characters after shift left | |
private const int MAI_HAN_AKAT_LEFT_SHIFT = 63248; | |
private const int SARA_I_LEFT_SHIFT = 63233; | |
private const int SARA_Ii_LEFT_SHIFT = 63234; | |
private const int SARA_Ue_LEFT_SHIFT = 63235; | |
private const int SARA_Uee_LEFT_SHIFT = 63236; | |
private const int MAI_TAI_KHU_LEFT_SHIFT = 63250; | |
// Upper level 2 characters | |
private const int MAI_EK = 3656; | |
private const int MAI_THO = 3657; | |
private const int MAI_TRI = 3658; | |
private const int MAI_CHATTAWA = 3659; | |
private const int THANTHAKHAT = 3660; | |
private const int NIKHAHIT = 3661; | |
// Upper level 2 characters after pull down | |
private const int MAI_EK_DOWN = 63242; | |
private const int MAI_THO_DOWN = 63243; | |
private const int MAI_TRI_DOWN = 63244; | |
private const int MAI_CHATTAWA_DOWN = 63245; | |
private const int THANTHAKHAT_DOWN = 63246; | |
// Upper level 2 characters after pull down and shift left | |
private const int MAI_EK_PULL_DOWN_AND_LEFT_SHIFT = 63237; | |
private const int MAI_THO_PULL_DOWN_AND_LEFT_SHIFT = 63238; | |
private const int MAI_TRI_PULL_DOWN_AND_LEFT_SHIFT = 63239; | |
private const int MAI_CHATTAWA_PULL_DOWN_AND_LEFT_SHIFT = 63240; | |
private const int THANTHAKHAT_PULL_DOWN_AND_LEFT_SHIFT = 63241; | |
// Upper level 2 characters after shift left | |
private const int MAI_EK_LEFT_SHIFT = 63251; | |
private const int MAI_THO_LEFT_SHIFT = 63252; | |
private const int MAI_TRI_LEFT_SHIFT = 63253; | |
private const int MAI_CHATTAWA_LEFT_SHIFT = 63254; | |
private const int THANTHAKHAT_LEFT_SHIFT = 63255; | |
private const int NIKHAHIT_LEFT_SHIFT = 63249; | |
// Up tail characters | |
private const int PO_PLA = 3611; | |
private const int FO_FA = 3613; | |
private const int FO_FAN = 3615; | |
private const int LOchULA = 3628; | |
// Down tail characters | |
private const int THO_THAN = 3600; | |
private const int YO_YING = 3597; | |
private const int DOchADA = 3598; | |
private const int TO_PATAK = 3599; | |
private const int RU = 3620; | |
private const int LU = 3622; | |
// Cut tail characters | |
private const int THO_THAN_CUT_TAIL = 63232; | |
private const int YO_YING_CUT_TAIL = 63247; | |
// for exploded SARA_AM (NIKHAHIT + SARA_AA) | |
private const int SARA_AA = 3634; | |
protected virtual void FixThaiVowel() | |
{ | |
// ExplodeSaraAm(); | |
int prevCode = 0; | |
int cutCode = 0; | |
for (int i = 0; m_char_buffer[i] != 0; i++) | |
{ | |
int code = m_char_buffer[i]; | |
if (IsUpperLevel1(code) && IsUpTail(prevCode)) | |
{ | |
m_char_buffer[i] = GetShiftLeftCharacter(code); | |
} | |
else if (IsUpperLevel2(code)) | |
{ | |
if (IsLowerLevel(prevCode)) | |
{ | |
prevCode = m_char_buffer[i - 2]; | |
} | |
if (IsUpTail(prevCode)) | |
{ | |
m_char_buffer[i] = GetPullDownAndShiftLeftCharacter(code); | |
} | |
else if (IsLeftShiftUpperLevel1(prevCode)) | |
{ | |
m_char_buffer[i] = GetShiftLeftCharacter(code); | |
} | |
else if (!IsUpperLevel1(prevCode)) | |
{ | |
m_char_buffer[i] = GetPullDownCharacter(code); | |
} | |
} | |
else if (IsLowerLevel(code) && IsDownTail(prevCode)) | |
{ | |
cutCode = GetCutTailCharacter(prevCode); | |
if (prevCode != cutCode) | |
{ | |
m_char_buffer[i - 1] = cutCode; | |
} | |
else | |
{ | |
m_char_buffer[i] = GetPullDownCharacter(code); | |
} | |
} | |
else if (IsSaraAm(code) && i > 0) | |
{ | |
if (IsPullDown(prevCode)) | |
{ | |
m_char_buffer[i - 1] = GetPullUpCharacter(prevCode); | |
} | |
} | |
prevCode = m_char_buffer[i]; | |
} | |
} | |
private void ExplodeSaraAm() | |
{ | |
if (CountSaraAm() == 0) return; | |
List<int> buffers = new List<int>(); | |
for (int i = 0; i < m_char_buffer.Length; i++) | |
{ | |
int charCode = m_char_buffer[i]; | |
if (i < m_char_buffer.Length - 1 && m_char_buffer[i + 1] == SARA_AM) | |
{ | |
if (IsUpperLevel2(charCode)) | |
{ | |
buffers.Add(NIKHAHIT); | |
buffers.Add(charCode); | |
} | |
else | |
{ | |
buffers.Add(charCode); | |
buffers.Add(NIKHAHIT); | |
} | |
} | |
else if (charCode == SARA_AM) | |
{ | |
buffers.Add(SARA_AA); | |
} | |
else | |
{ | |
buffers.Add(charCode); | |
} | |
} | |
m_char_buffer = buffers.ToArray(); | |
} | |
private int GetPullUpCharacter(int charCode) | |
{ | |
switch (charCode) | |
{ | |
case MAI_EK_DOWN: return MAI_EK; | |
case MAI_THO_DOWN: return MAI_THO; | |
case MAI_TRI_DOWN: return MAI_TRI; | |
case MAI_CHATTAWA_DOWN: return MAI_CHATTAWA; | |
case THANTHAKHAT_DOWN: return THANTHAKHAT; | |
case SARA_U_DOWN: return SARA_U; | |
case SARA_UU_DOWN: return SARA_UU; | |
case PHINTHU_DOWN: return PHINTHU; | |
default: return charCode; | |
} | |
} | |
private int GetPullDownCharacter(int charCode) | |
{ | |
switch (charCode) | |
{ | |
case MAI_EK: return MAI_EK_DOWN; | |
case MAI_THO: return MAI_THO_DOWN; | |
case MAI_TRI: return MAI_TRI_DOWN; | |
case MAI_CHATTAWA: return MAI_CHATTAWA_DOWN; | |
case THANTHAKHAT: return THANTHAKHAT_DOWN; | |
case SARA_U: return SARA_U_DOWN; | |
case SARA_UU: return SARA_UU_DOWN; | |
case PHINTHU: return PHINTHU_DOWN; | |
default: return charCode; | |
} | |
} | |
private int GetCutTailCharacter(int charCode) | |
{ | |
switch (charCode) | |
{ | |
case THO_THAN: return THO_THAN_CUT_TAIL; | |
case YO_YING: return YO_YING_CUT_TAIL; | |
default: return charCode; | |
} | |
} | |
private int GetShiftLeftCharacter(int charCode) | |
{ | |
switch (charCode) | |
{ | |
case MAI_EK: return MAI_EK_LEFT_SHIFT; | |
case MAI_THO: return MAI_THO_LEFT_SHIFT; | |
case MAI_TRI: return MAI_TRI_LEFT_SHIFT; | |
case MAI_CHATTAWA: return MAI_CHATTAWA_LEFT_SHIFT; | |
case MAI_HAN_AKAT: return MAI_HAN_AKAT_LEFT_SHIFT; | |
case SARA_I: return SARA_I_LEFT_SHIFT; | |
case SARA_Ii: return SARA_Ii_LEFT_SHIFT; | |
case SARA_Ue: return SARA_Ue_LEFT_SHIFT; | |
case SARA_Uee: return SARA_Uee_LEFT_SHIFT; | |
case MAI_TAI_KHU: return MAI_TAI_KHU_LEFT_SHIFT; | |
case NIKHAHIT: return NIKHAHIT_LEFT_SHIFT; | |
default: return charCode; | |
} | |
} | |
private int GetPullDownAndShiftLeftCharacter(int charCode) | |
{ | |
switch (charCode) | |
{ | |
case MAI_EK: return MAI_EK_PULL_DOWN_AND_LEFT_SHIFT; | |
case MAI_THO: return MAI_THO_PULL_DOWN_AND_LEFT_SHIFT; | |
case MAI_TRI: return MAI_TRI_PULL_DOWN_AND_LEFT_SHIFT; | |
case MAI_CHATTAWA: return MAI_CHATTAWA_PULL_DOWN_AND_LEFT_SHIFT; | |
case MAI_HAN_AKAT: return MAI_HAN_AKAT_LEFT_SHIFT; | |
case THANTHAKHAT: return THANTHAKHAT_PULL_DOWN_AND_LEFT_SHIFT; | |
default: return charCode; | |
} | |
} | |
private bool IsPullDown(int charCode) | |
{ | |
return charCode == MAI_EK_DOWN || charCode == MAI_THO_DOWN || | |
charCode == MAI_TRI_DOWN || charCode == MAI_CHATTAWA_DOWN || | |
charCode == THANTHAKHAT_DOWN || charCode == SARA_U_DOWN || | |
charCode == SARA_UU_DOWN || charCode == PHINTHU_DOWN; | |
} | |
private bool IsUpTail(int charCode) | |
{ | |
return charCode == PO_PLA || charCode == FO_FA || charCode == FO_FAN | |
|| charCode == LOchULA; | |
} | |
private bool IsDownTail(int charCode) | |
{ | |
return charCode == THO_THAN || charCode == YO_YING || charCode == DOchADA | |
|| charCode == TO_PATAK || charCode == RU || charCode == LU; | |
} | |
private bool IsUpperLevel1(int charCode) | |
{ | |
return charCode == MAI_HAN_AKAT || charCode == SARA_I || charCode == SARA_Ii | |
|| charCode == SARA_Ue || charCode == SARA_Uee || charCode == MAI_TAI_KHU | |
|| charCode == NIKHAHIT; | |
} | |
private bool IsUpperLevel2(int charCode) | |
{ | |
return charCode == MAI_EK || charCode == MAI_THO || charCode == MAI_TRI | |
|| charCode == MAI_CHATTAWA || charCode == THANTHAKHAT; | |
} | |
private bool IsLeftShiftUpperLevel1(int charCode) | |
{ | |
return charCode == MAI_HAN_AKAT_LEFT_SHIFT || charCode == SARA_I_LEFT_SHIFT | |
|| charCode == SARA_Ii_LEFT_SHIFT || charCode == SARA_Ue_LEFT_SHIFT | |
|| charCode == SARA_Uee_LEFT_SHIFT || charCode == MAI_TAI_KHU_LEFT_SHIFT | |
|| charCode == NIKHAHIT_LEFT_SHIFT; | |
} | |
private bool IsLowerLevel(int charCode) | |
{ | |
return charCode == SARA_U || charCode == SARA_UU || charCode == PHINTHU; | |
} | |
private bool IsSaraAm(int charCode) | |
{ | |
return charCode == SARA_AM; | |
} | |
private int CountSaraAm() | |
{ | |
int count = 0; | |
for (int i = 0; m_char_buffer[i] != 0; i++) | |
{ | |
if (m_char_buffer[i] == SARA_AM) | |
{ | |
count++; | |
} | |
} | |
return count; | |
} | |
#endregion | |
allfake
commented
Apr 24, 2017
For now, Go here https://github.com/rutcreate/TextMesh-Pro-Thai.git
Add
"com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git"
To manifest.json in your project
If you use textmeshpro then replace instead of add
Like this
"com.unity.textmeshpro": "2.1.1",
to
"com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git",
เปลี่ยนไปใช้อันนี้เน้อว https://github.com/rutcreate/TextMesh-Pro-Thai.git
เพิ่ม
"com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git"
ใน manifest.json ใน unity proejct นะ
ถ้าใช้ textmeshpro อยู่แล้วก็แก้จาก
"com.unity.textmeshpro": "2.1.1",
เป็น
"com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git",
Character set view here
https://gist.github.com/allfake/1d5a64c2a1eca36a660c
Or just thai and english
Character set => Unicode Range(Hex) in font asset creator
00,0D,20-7E,A0-B4,B6-FF,2BB-2BC,2BE-2BF,2C6-2CC,2D8-2DD,E01-E3A,E3F-E5B,F700-F710,F712-F71A