void GetCharacterAtPoint(Vector2 point, out int lineIndex, out int lineCharIndex) { // Get the line if (IsMultiLine) { lineIndex = LineBufferOffset + (int)Math.Floor(point.Y / Font.GetLineSpacing()); if (lineIndex >= _lines.Count) { lineIndex = _lines.Count - 1; } } else { lineIndex = 0; } // Get the character if (IsMultiLine) { lineCharIndex = StyledText.FindLastFittingChar(_lines[lineIndex].LineText, Font, (int)point.X); } else { var substr = _lines[lineIndex].LineText.Substring(LineCharBufferOffset); lineCharIndex = StyledText.FindLastFittingChar(substr, Font, (int)point.X); lineCharIndex += LineCharBufferOffset; } if (lineCharIndex > _lines[lineIndex].LineText.Length) { lineCharIndex = _lines[lineIndex].LineText.Length; } }
public int CountFittingCharactersLeft(Font font, int startChar, int maxLineLength) { string subStr; if (startChar == 0) { subStr = _lineText; } else if (startChar >= _lineText.Length) { return(1); } else { subStr = _lineText.Substring(startChar); } return(StyledText.FindLastFittingChar(subStr, font, maxLineLength)); }