Skip to content

Commit 7d04204

Browse files
authored
FEAT: IsForceFullLineHeight option to fix line spcaing issue in Unity 6
1 parent 3f38a22 commit 7d04204

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Editor/ThaiTextNurse/ThaiTextNurseEditor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ public override void OnInspectorGUI()
2626
if (settings == null)
2727
EditorGUILayout.HelpBox("ThaiTextCareSettings.asset is missing. It must be under: " + ThaiTextCareSettings.SettingsPath , MessageType.Error);
2828
else if (!ThaiTextNurse.IsDictionaryLoaded)
29+
{
2930
EditorGUILayout.HelpBox("Dictionary is not loaded. It must be under 'Resources' folder: " + ThaiTextNurse.GetDictionaryPath(settings) , MessageType.Error);
31+
EditorGUILayout.BeginHorizontal();
32+
GUILayout.FlexibleSpace();
33+
var isRefresh = GUILayout.Button("Refresh", GUILayout.ExpandWidth(false));
34+
EditorGUILayout.EndHorizontal();
35+
if (isRefresh)
36+
ThaiTextNurse.RebuildDictionary();
37+
}
3038

3139
EditorGUI.BeginDisabledGroup(!ThaiTextNurse.IsDictionaryLoaded || settings == null);
3240
var currentText = nurse.OutputString;
@@ -50,6 +58,9 @@ public override void OnInspectorGUI()
5058
EditorGUILayout.EndHorizontal();
5159
}
5260
}
61+
62+
PropertyField("isForceFullLineHeight");
63+
5364
EditorGUILayout.BeginHorizontal();
5465
PropertyField("isTokenize");
5566
if (serializedObject.FindProperty("isTokenize").boolValue)

Runtime/ThaiTextNurse/ThaiTextNurse.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public ThaiGlyphCorrection Correction
2424
}
2525
}
2626
[SerializeField] ThaiGlyphCorrection correction;
27+
28+
public bool IsForceFullLineHeight
29+
{
30+
get => isForceFullLineHeight;
31+
set
32+
{
33+
isForceFullLineHeight = value;
34+
NotifyChange();
35+
}
36+
}
37+
38+
[Tooltip("Force inject <line-height=100%> tag to the output string to fix the issue where line spacing increase as you modify the Glyph adjusment Y offset.")]
39+
[SerializeField] bool isForceFullLineHeight;
2740

2841
public bool IsTokenize
2942
{
@@ -126,7 +139,10 @@ string RebuildOutputString(string text)
126139
if (correction != ThaiGlyphCorrection.None)
127140
outputString = ThaiFontAdjuster.Adjust(outputString, correction);
128141

129-
return outputString;
142+
if (isForceFullLineHeight)
143+
return $"<line-height=100%>{outputString}</line-height>";
144+
else
145+
return outputString;
130146
}
131147

132148
string Tokenize()

0 commit comments

Comments
 (0)