/// <summary> /// Setups this class. Called during OnGUI. /// </summary> internal static void Setup() { Normal = EditorStyles.standardFont; Bold = EditorStyles.boldFont; Small = EditorStyles.miniFont; Big = (Font)EditorGUIUtility.LoadRequired("Fonts/Lucida Grande Big.ttf"); if (Big == null) { Big = Normal; } #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(Normal != null); Debug.Assert(Small != null); Debug.Assert(Big != null); Debug.Assert(Bold != null); #endif NormalSizes = new FontCharSizes(Normal, EditorStyles.label.fontSize); SmallSizes = new FontCharSizes(Small, EditorStyles.miniButton.fontSize); #if DEV_MODE && DEBUG_ENABLED Debug.Log("Normal=" + Normal.name + ", Small=" + Small.name + ", Big=" + Big.name + ", Bold=" + Bold.name); #endif }
private float Width(FontCharSizes fontCharSizes) { float largestWidth = 100f; float lineWidth = 0f; for (int n = blocks.Count - 1; n >= 0; n--) { var block = blocks[n]; if (block.IsLineBreak()) { if (lineWidth > largestWidth) { largestWidth = lineWidth; } lineWidth = 0f; } else { lineWidth += fontCharSizes.GetTextWidth(block.ContentUnformatted); } } return(largestWidth); }
public void ToCode(ref Code result, ITextSyntaxFormatter builder, FontCharSizes fontCharSizes) { ToCodeLines(ref result.lines, builder); result.width = Width(fontCharSizes); }