public CharData Get(char id) { CharData val = null; if (CharDatas.TryGetValue((int)id, out val)) { return(val); } return(null); }
public int WidthOf(string str) { int width = 0; for (int i = 0; i < str.Length; i++) { if (CharDatas.ContainsKey((int)str[i])) { width += CharDatas[(int)str[i]].XAdvance; } } return(width); }
public Vector2 Measure(string str) { Vector2 size = new Vector2(0, LineHeight); int lineWidth = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == '\n') { size.Y += LineHeight; size.X = Math.Max(lineWidth, size.X); lineWidth = 0; } else if (CharDatas.ContainsKey((int)str[i])) { lineWidth += CharDatas[(int)str[i]].XAdvance; } } size.X = Math.Max(lineWidth, size.X); return(size); }
public int WidthOf(char character) { return(CharDatas.ContainsKey((int)character) ? CharDatas[(int)character].XAdvance : 0); }