void UpdateTextRows(string text) { // Do nothing if text has not changed since last time bool sdfState = font.IsSDFCapable; if (text == lastText && sdfState == previousSDFState) { 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.CalculateTextWidth(textRows[i], LocalScale); if (width > widestRow) { widestRow = width; } } previousSDFState = sdfState; }
float GetCharacterWidthToCursor() { if (font == null) { return(0); } return(font.CalculateTextWidth(text, LocalScale, 0, cursorPosition)); }