Exemplo n.º 1
0
        public static TexCharMetric Get(TexChar Char, float Height, float Depth, float Bearing, float Italic, float Width, float Scale)
        {
            var metric = ObjPool <TexCharMetric> .Get();

            metric.ch           = Char;
            metric.height       = Height * Scale;
            metric.depth        = Depth * Scale;
            metric.bearing      = Bearing * Scale;
            metric.italic       = Italic * Scale;
            metric.width        = Width * Scale;
            metric.appliedScale = Scale;
            return(metric);
        }
Exemplo n.º 2
0
 GUIStyle SubDetermineStyle(TexChar c)
 {
     if (!string.IsNullOrEmpty(c.symbolName))
     {
         return(Styles.FontPreviewSymbols);
     }
     else if (c.nextLargerExist || c.extensionExist)
     {
         return(Styles.FontPreviewRelation);
     }
     else
     {
         return(Styles.FontPreviewEnabled);
     }
 }
Exemplo n.º 3
0
        public static SymbolAtom Get(TexChar ch, char tag)
        {
            if (ch == null)
            {
                return(null);
            }
            var atom = ObjPool <SymbolAtom> .Get();

            atom.Type        = ch.type;
            atom.Name        = ch.symbolName;
            atom.IsDelimiter = (ch.extensionExist || ch.nextLargerExist) && !(ch.extensionHorizontal) &&
                               (ch.type >= CharType.Relation && ch.type <= CharType.CloseDelimiter);
            atom.Character  = ch;
            atom.TaggedChar = tag;
            return(atom);
        }
Exemplo n.º 4
0
    void DrawSetter()
    {
        GUILayout.Label(selectedAsset.id, Styles.SetterTitle, GUILayout.MaxHeight(25));
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("ID");
            GUILayout.Label(string.Format("<b>{0}</b> (#{1:X})", selectedAsset.id, selectedAsset.index), Styles.SetterFont);
        }
        EditorGUILayout.EndHorizontal();
        TexChar c = selectedChar;
        //        if (c.supported)
        {
            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < 2; i++)
            {
                if (GUILayout.Toggle(i == setterState, Styles.SetterHeaderContent[i], Styles.SetterHeader[i]))
                {
                    setterState = i;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.BeginChangeCheck();
            if (setterState == 0)
            {
                // Create an thumbnail
                switch (selectedAsset.type)
                {
                case TexAssetType.Font:
                    EditorGUILayout.LabelField(Styles.GetCharMapContent(selectedAsset.chars[selectedCharIdx].characterIndex),
                                               Styles.SetterPreview, GUILayout.Height(selectedFont.asset.lineHeight * 2.2f));
                    break;

                case TexAssetType.Sprite:
                    Rect r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSprite.lineHeight * EditorGUIUtility.labelWidth));
                    EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview);
                    r2.width *= .5f;
                    r2.x     += r2.width * .5f;

                    var sprt = selectedSprite.GenerateMetric(selectedChar.characterIndex);
                    GUI.DrawTextureWithTexCoords(r2, selectedSprite.Texture(), sprt.uv);
                    break;

#if TEXDRAW_TMP
                case TexAssetType.FontSigned:
                    r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSigned.LineHeight() * EditorGUIUtility.labelWidth));
                    EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview);
                    r2.width *= .5f;
                    r2.x     += r2.width * .5f;

                    sprt = selectedSigned.GenerateMetric(selectedChar.characterIndex);
                    GUI.DrawTextureWithTexCoords(r2, selectedSigned.asset.atlas, sprt.uv);
                    break;
#endif
                default:
                    break;
                }

                // Basic info stuff
                EditorGUILayout.LabelField("Index", string.Format("<b>{0}</b> (#{0:X2})", selectedCharIdx), Styles.SetterFont);
                EditorGUILayout.LabelField("Character Index", "<b>" +
                                           selectedChar.characterIndex.ToString() + "</b> (#" + ((int)selectedChar.characterIndex).ToString("X2")
                                           + ")", Styles.SetterFont);

                EditorGUILayout.LabelField("Symbol Definition");
                EditorGUILayout.BeginHorizontal();
                {
                    c.symbolAlt  = EditorGUILayout.TextField(c.symbolAlt);  //Secondary
                    c.symbolName = EditorGUILayout.TextField(c.symbolName); //Primary
                }
                EditorGUILayout.EndHorizontal();

                c.type = (CharType)EditorGUILayout.EnumPopup("Symbol Type", c.type);
                EditorGUILayout.LabelField("In math, this mapped as:");
                c.characterMap = EditorGUILayout.IntPopup(c.characterMap, Styles.SetterCharMap, Styles.SetterCharMapInt);
            }
            else
            {
                SetterScroll = EditorGUILayout.BeginScrollView(SetterScroll, GUILayout.ExpandHeight(true));
                {
                    EditorGUILayout.LabelField(string.Format("Hash \t : <b>{0}</b> (#{1:X1}{2:X2})", selectedFontIdx * 256 + selectedCharIdx, selectedFontIdx, selectedCharIdx), Styles.SetterFont);
                    c.nextLargerHash = SubDrawThumbnail(c.nextLargerHash, "Is Larger Character Exist?", Styles.SetterNextLarger);
                    EditorGUILayout.Space();
                    if (EditorGUILayout.ToggleLeft("Is Part of Extension?", c.extensionExist))
                    {
                        EditorGUI.indentLevel++;
                        c.extensionExist      = true;
                        c.extensionHorizontal = EditorGUILayout.ToggleLeft("Is This Horizontal?", c.extensionHorizontal);

                        c.extentTopHash    = SubDrawThumbnail(c.extentTopHash, c.extensionHorizontal ? "Has Left Extension?" : "Has Top Extension?", Styles.SetterExtendTop);
                        c.extentMiddleHash = SubDrawThumbnail(c.extentMiddleHash, "Has Middle Extension?", Styles.SetterExtendMiddle);
                        c.extentBottomHash = SubDrawThumbnail(c.extentBottomHash, c.extensionHorizontal ? "Has Right Extension?" : "Has Bottom Extension?", Styles.SetterExtendBottom);
                        c.extentRepeatHash = SubDrawThumbnail(c.extentRepeatHash, "Has Tiled Extension?", Styles.SetterExtendRepeat);

                        EditorGUI.indentLevel--;
                    }
                    else
                    {
                        c.extensionExist = false;
                    }
                }
                EditorGUILayout.EndScrollView();
            }
            if (EditorGUI.EndChangeCheck())
            {
                RecordDirty();
                lastCharChanged = true;
            }
        }
    }