public static CharacterLayout[] LayoutCharacters( RuntimeFont font, string str, int startX, int startY ) { CharacterLayout[] layout = new CharacterLayout[ str.Length ]; int curX = startX; int curY = startY; for ( int i=0; i < str.Length; i++ ) { int whichCharacter = font.FindCharacter( str[i] ); if ( whichCharacter == -1 ) continue; layout[i].SudoFontIndex = whichCharacter; layout[i].XOffset = (int)( curX + font.Characters[whichCharacter].XOffset * font.RuntimeScale ); layout[i].YOffset = (int)( curY + font.Characters[whichCharacter].YOffset * font.RuntimeScale ); float totalXAdvance = font.Characters[whichCharacter].XAdvance * font.RuntimeScale; if ( i+1 < str.Length ) totalXAdvance += font.Characters[whichCharacter].GetKerning( str[i+1] ) * font.RuntimeScale; curX += (int)Math.Ceiling( totalXAdvance ); } return layout; }
public static CharacterLayout[] LayoutCharacters(RuntimeFont font, string str, int startX, int startY) { CharacterLayout[] layout = new CharacterLayout[str.Length]; int curX = startX; int curY = startY; for (int i = 0; i < str.Length; i++) { int whichCharacter = font.FindCharacter(str[i]); if (whichCharacter == -1) { continue; } layout[i].SudoFontIndex = whichCharacter; layout[i].XOffset = (int)(curX + font.Characters[whichCharacter].XOffset * font.RuntimeScale); layout[i].YOffset = (int)(curY + font.Characters[whichCharacter].YOffset * font.RuntimeScale); float totalXAdvance = font.Characters[whichCharacter].XAdvance * font.RuntimeScale; if (i + 1 < str.Length) { totalXAdvance += font.Characters[whichCharacter].GetKerning(str[i + 1]) * font.RuntimeScale; } curX += (int)Math.Ceiling(totalXAdvance); } return(layout); }
public CharacterTable(string rawTableData) { CharacterLayout layout = JsonUtility.FromJson <CharacterLayout>(rawTableData); m_characterValue = layout.value; if (m_characterValue == null) { Debug.LogError("Character table data is wrong."); } }