void DrawManager() { ManagerScroll = EditorGUILayout.BeginScrollView(ManagerScroll, false, false, GUILayout.ExpandHeight(true)); //EditorGUILayout.BeginVertical(GUILayout.Width(EditorGUIUtility.labelWidth - 90)); int Total = targetPreference.fontData.Length; //EditorGUI.indentLevel = 0; for (int i = 0; i < Total; i++) { //Draw Headers First, if needed if (i == 0) { GUILayout.Label("Math Fonts", Styles.ManagerFamily); } else if (i == targetPreference.header_mathCount) { GUILayout.Label("User Fonts", Styles.ManagerFamily); } else if (i == targetPreference.header_userCount) { GUILayout.Label("Sprites", Styles.ManagerFamily); } //Draw the font TexFont d = targetPreference.fontData[i]; if ((selectedFontIdx == i) != GUILayout.Toggle(selectedFontIdx == i, d.id, Styles.ManagerChild)) { selectedFontIdx = i; selectedCharIdx = Mathf.Clamp(selectedCharIdx, 0, d.chars.Length - 1); SetPreviewFont(d.Font_Asset); } } //EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
void DrawViewerFont(Rect drawRect, TexFont selectedFont) { if (!selectedFont.Font_Asset) { // Something wrong? EditorGUI.LabelField(drawRect, "The Font Asset is NULL. This Asset might currently unused.", Styles.ImporterOptionFontStyle); return; } //Rect r; Vector2 childSize = new Vector2(drawRect.width / 8f - 4, selectedFont.Font_Asset.lineHeight * (drawRect.width / 250) + 15); ViewerScroll = GUI.BeginScrollView(drawRect, ViewerScroll, new Rect(Vector2.zero, new Vector2((childSize.x + 2) * 8 - 2, (childSize.y + 2) * 16))); Styles.FontPreviewEnabled.fontSize = (int)childSize.x / 2; Styles.FontPreviewSymbols.fontSize = (int)childSize.x / 2; Styles.FontPreviewRelation.fontSize = (int)childSize.x / 2; var chars = selectedFont.chars; for (int i = 0; i < chars.Length; i++) { int x = i % 8, y = i / 8, l = selectedCharIdx; var r = new Rect(new Vector2((childSize.x + 2) * x, (childSize.y + 2) * y), childSize); var ch = chars[i]; if (CustomToggle(r, selectedCharIdx == i, ch.supported, Styles.GetCharMapContent(ch.characterIndex), SubDetermineStyle(ch))) { int newS = i + (selectedCharIdx - l); selectedCharIdx = newS; } } GUI.EndScrollView(); }
void DrawViewerSprite(Rect drawRect, TexFont selectedFont) { if (!selectedFont.Sprite_Asset) { // Something wrong? EditorGUI.LabelField(drawRect, "The Sprite Asset is NULL. This Asset might currently unused.", Styles.ImporterOptionFontStyle); return; } int tileX = selectedFont.sprite_xLength, tileY = selectedFont.sprite_yLength, columnTile = 0; bool horizonFirst = tileX >= tileY; columnTile = horizonFirst ? tileY : tileX; Vector2 childSize = new Vector2((drawRect.width - 24) / columnTile, selectedFont.font_lineHeight * (drawRect.width - 24) / columnTile); ViewerScroll = GUI.BeginScrollView(drawRect, ViewerScroll, new Rect(Vector2.zero, new Vector2((childSize.x + 2) * columnTile - 2, (childSize.y + 2) * (horizonFirst ? tileX : tileY)))); var chars = selectedFont.chars; for (int i = 0; i < chars.Length; i++) { int x = i % columnTile, y = i / columnTile, l = selectedCharIdx; var r = new Rect(new Vector2((childSize.x + 2) * x, (childSize.y + 2) * y), childSize); var ch = chars[i]; if (CustomToggle(r, selectedCharIdx == i, ch.supported, GUIContent.none, SubDetermineStyle(ch))) { int newS = i + (selectedCharIdx - l); selectedCharIdx = newS; } if (ch.supported) { #if TEXDRAW_TMP // Additional measurements for accurate display in TMP var r2 = r; var ratio = Mathf.Min(1, (ch.height + ch.depth) / selectedFont.font_lineHeight); r.height *= ratio; r.width = (ch.bearing + ch.italic) / (ch.height + ch.depth) * r.height; r.y += (r2.height - r.height) / 2f; r.x += (r2.width - r.width) / 2f; #endif GUI.DrawTextureWithTexCoords(r, selectedFont.Sprite_Asset, ch.sprite_uv); } } GUI.EndScrollView(); }
void DrawOptionsPanel(TexFont selectedFont) { // Draw the header EditorGUILayout.LabelField(selectedFont.id, EditorStyles.largeLabel); if (!selectedFont.supported) { return; } var sel = (FontStyle)EditorGUILayout.EnumPopup("Preview", selectedStyle); if (sel != selectedStyle) { selectedStyle = sel; Styles.FontPreviewEnabled.fontStyle = sel; Styles.FontPreviewSymbols.fontStyle = sel; Styles.FontPreviewRelation.fontStyle = sel; Styles.SetterPreview.fontStyle = sel; } EditorGUILayout.Space(); // Preview the font var ch = selectedFont.chars[selectedCharIdx]; if (!ch.supported) { EditorGUILayout.HelpBox("Character isn't available", MessageType.Info); return; } if (selectedFont.type == TexFontType.Font) { EditorGUILayout.LabelField(Styles.GetCharMapContent(ch.characterIndex), Styles.SetterPreview, GUILayout.Height(selectedFont.Font_Asset.lineHeight * 2.2f) /*..*/); } else { Rect r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedFont.font_lineHeight * EditorGUIUtility.labelWidth) /*..*/); EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview); GUI.DrawTextureWithTexCoords(r2, selectedFont.Sprite_Asset, ch.sprite_uv); } EditorGUILayout.Space(); // Draw stats EditorGUILayout.LabelField("Character", string.Format("{0} U+{1}", ch.characterIndex, ((int)ch.characterIndex).ToString("X"))); EditorGUILayout.LabelField("Index", string.Format("{0} #{1}", ch.index, (ch.ToHash()).ToString("X3"))); if (!string.IsNullOrEmpty(ch.symbolName)) { EditorGUILayout.Space(); if (string.IsNullOrEmpty(ch.symbolAlt)) { EditorGUILayout.LabelField("Symbol", "\\" + ch.symbolName); } else { EditorGUILayout.LabelField("Symbol", string.Format("\\{0} / \\{1}", ch.symbolName, ch.symbolAlt)); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Metric Size", string.Format("{0} x {1}", (ch.bearing + ch.italic).ToString("0.00"), (ch.depth + ch.height).ToString("0.00"))); EditorGUILayout.LabelField("Height", ch.height.ToString("0.000")); EditorGUILayout.LabelField("Depth", ch.depth.ToString("0.000")); EditorGUILayout.LabelField("Bearing", ch.bearing.ToString("0.000")); EditorGUILayout.LabelField("Italic", ch.italic.ToString("0.000")); EditorGUILayout.LabelField("Advance", ch.width.ToString("0.000")); EditorGUILayout.Space(); DrawRelationButton("Larger Char", ch.nextLargerHash); if (ch.extensionExist) { EditorGUILayout.LabelField("Part of extension"); if (ch.extensionHorizontal) { DrawRelationButton("Left Extent", ch.extentTopHash); DrawRelationButton("Middle Extent", ch.extentMiddleHash); DrawRelationButton("Right Extent", ch.extentBottomHash); DrawRelationButton("Tiled Extent", ch.extentRepeatHash); } else { DrawRelationButton("Top Extent", ch.extentTopHash); DrawRelationButton("Middle Extent", ch.extentMiddleHash); DrawRelationButton("Bottom Extent", ch.extentBottomHash); DrawRelationButton("Tiled Extent", ch.extentRepeatHash); } } }