I am attempting to create a script that when a line of text would be approaching the width of the line it would attempt to wrap the text properly (ie. if the character is not '-' or ' ' then add a hyphen between letters of a word (like how word editing software does it) but when I attempt to run it a bunch of my characters disappear.
This is the text that I am testing with, "An Aberration has a bizarre anatomy, strange abilities, an alien mindset, or any combination of the three."
but these are the results of my test script
"Found with info (' ','e','r','a','t','i','o','h','s','l','d')" "Found without info ('A','n','b','z','m','y',',','g','c','f','.')" "Didnt Find ()"
and the output from compiling the text using only the characters that have available info is " erratio has a iarre aato strae ailities a alie idset or a oiatio o the three"
and here is my testing script
public class Test : MonoBehaviour
{
[SerializeField]
private Type m_Type;
// Not System.Type, is a custom class
[SerializeField]
private Font m_Font;
// Set to Arial for testing.
private List<string> m_FoundWithInfo;
private List<string> m_FoundWithoutInfo;
private List<string> m_DidntFind;
private void Awake()
{
m_FoundWithInfo = new List<string>();
m_FoundWithoutInfo = new List<string>();
m_DidntFind = new List<string>();
foreach (char c in m_Type.GetDescription())
{
if (m_Font.HasCharacter(c))
{
if (m_Font.GetCharacterInfo(c,
out CharacterInfo info, 14, FontStyle.Normal))
{
if (!m_FoundWithInfo.Contains($"'{c}'"))
{
m_FoundWithInfo.Add($"'{c}'");
}
}
else
{
if (!m_FoundWithoutInfo.Contains($"'{c}'"))
{
m_FoundWithoutInfo.Add($"'{c}'");
}
}
}
else
{
if (!m_DidntFind.Contains($"'{c}'"))
{
m_DidntFind.Add($"'{c}'");
}
}
}
Debug.Log($"Found with info ({string.Join(",", m_FoundWithInfo)})");
Debug.Log($"Found without info ({string.Join(",", m_FoundWithoutInfo)})");
Debug.Log($"Didnt Find ({string.Join(",", m_DidntFind)})");
}
}
How can I make this work so that the returned text is otherwise identical to the original?
To clarify the Test script only checks to see what necessary characters don't have any CharacterInfo associated with them.