void UpdateTextRows(string text) { // Do nothing if text has not changed since last time if (text == lastText) { return; } // Split into rows based on \r escape character textRows = text.Split('\r'); // Set text we just processed lastText = text; // Find widest row widestRow = 0; for (int i = 0; i < textRows.Length; i++) { float width = font.GetCharacterWidth(textRows[i]); if (width > widestRow) { widestRow = width; } } }
void UpdateTextRows(string text) { // Do nothing if text has not changed since last time if (text == lastText) { return; } // Split into rows based on \r escape character // Text read from plain-text files will become \\r so need to replace this first text = text.Replace("\\r", "\r"); textRows = text.Split('\r'); // Set text we just processed lastText = text; // Find widest row widestRow = 0; for (int i = 0; i < textRows.Length; i++) { float width = font.GetCharacterWidth(textRows[i]); if (width > widestRow) { widestRow = width; } } }
float GetCharacterWidthToCursor() { if (font == null) { return(0); } return(font.GetCharacterWidth(text, cursorPosition)); }