public static VectorImageSet GenerateSpecificIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            string[] sections = fontDataContent.Split(new[] { "}" }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < sections.Length; i++)
            {
                if (i < 2)
                {
                    continue;
                }

                Glyph currentGlyph = new Glyph();

                currentGlyph.name = sections[i].Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries)[0].Replace(".icon-", "").Replace("\n", "").Replace(" ", "");

                if (string.IsNullOrEmpty(currentGlyph.name))
                {
                    continue;
                }

                currentGlyph.unicode = sections[i].Split(new[] { "\"" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("e", "E").Replace(@"\", "");

                vectorImageSet.iconGlyphList.Add(currentGlyph);
            }

            return(vectorImageSet);
        }
Exemplo n.º 2
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith("    id:"))
                {
                    currentGlyph      = new Glyph();
                    currentGlyph.name = line.Substring(line.IndexOf(":") + 1).Trim();
                }

                if (line.StartsWith("    unicode:"))
                {
                    if (currentGlyph != null)
                    {
                        currentGlyph.unicode = line.Substring(line.IndexOf(":") + 1).Trim();
                        vectorImageSet.iconGlyphList.Add(currentGlyph);
                        currentGlyph = null;
                    }
                }
            }

            return(vectorImageSet);
        }
Exemplo n.º 3
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith(".map-icon") && line.EndsWith(":before {"))
                {
                    currentGlyph = new Glyph();

                    string name = line.Replace(".map-icon-", string.Empty).Replace(":before {", string.Empty).Trim();
                    currentGlyph.name = name;
                }

                if (line.StartsWith("	content:"))
                {
                    if (currentGlyph != null)
                    {
                        string unicode = line.Substring(line.IndexOf("\"") + 2).Trim();
                        unicode = unicode.Substring(0, unicode.IndexOf("\";")).Trim();
                        currentGlyph.unicode = unicode;

                        vectorImageSet.iconGlyphList.Add(currentGlyph);
                        currentGlyph = null;
                    }
                }
            }

            return(vectorImageSet);
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

#if UNITY_5_2
            JsonData jsonData  = JsonMapper.ToObject(fontDataContent);
            JsonData iconArray = jsonData["icons"];

            for (int i = 0; i < iconArray.Count; i++)
            {
                JsonData iconData = iconArray[i];
                string   name     = iconData["name"].ToString();
                string   unicode  = iconData["code"].ToString();
                unicode = unicode.Replace("0x", string.Empty);

                vectorImageSet.iconGlyphList.Add(new Glyph(name, unicode, false));
            }
#else
            fontDataContent = fontDataContent.Replace("name", "m_Name").Replace("code", "m_Unicode").Replace("icons", "m_IconGlyphList");

            VectorImageSet ioniconsInfo = JsonUtility.FromJson <VectorImageSet>(fontDataContent);

            for (int i = 0; i < ioniconsInfo.iconGlyphList.Count; i++)
            {
                string name    = ioniconsInfo.iconGlyphList[i].name;
                string unicode = ioniconsInfo.iconGlyphList[i].unicode;
                unicode = unicode.Replace("0x", string.Empty);

                vectorImageSet.iconGlyphList.Add(new Glyph(name, unicode, false));
            }
#endif

            return(vectorImageSet);
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith("            <div class=\"icon-wrap\">"))
                {
                    currentGlyph = new Glyph();
                }

                if (line.StartsWith("              <div class=\"icon-name\">"))
                {
                    string name = line.Substring(line.IndexOf(">") + 1).Trim();
                    name = name.Substring(0, name.IndexOf("</div>")).Trim();
                    currentGlyph.name = name;
                }

                if (line.StartsWith("              <div class=\"icon_unicode\">"))
                {
                    if (currentGlyph != null)
                    {
                        string unicode = line.Substring(line.IndexOf(">") + 1).Trim();
                        unicode = unicode.Substring(0, unicode.IndexOf("</div>")).Trim();
                        currentGlyph.unicode = unicode;

                        vectorImageSet.iconGlyphList.Add(currentGlyph);
                        currentGlyph = null;
                    }
                }
            }

            return(vectorImageSet);
        }
        public VectorImageSet GetCachedIconSet()
        {
            if (m_CachedVectorImageSet == null)
            {
                m_CachedVectorImageSet = GetIconSet();
            }

            return(m_CachedVectorImageSet);
        }
Exemplo n.º 7
0
        static MaterialUIIconHelper()
        {
            if (m_Font == null)
            {
                m_Font = VectorImageManager.GetIconFont(VectorImageManager.materialUIIconsFontName);
            }

            if (m_IconSet == null)
            {
                m_IconSet = VectorImageManager.GetIconSet(VectorImageManager.materialUIIconsFontName);
            }
        }
        private void FormatNames(VectorImageSet set)
        {
            for (int i = 0; i < set.iconGlyphList.Count; i++)
            {
                string name = set.iconGlyphList[i].name;
                name = name.Replace("-", "_");
                name = name.Replace(" ", "_");
                name = name.ToLower();
                set.iconGlyphList[i].name = name;

                string unicode = set.iconGlyphList[i].unicode;
                unicode = unicode.Replace("\\u", "");
                unicode = unicode.Replace("\\\\u", "");
                set.iconGlyphList[i].unicode = unicode;
            }
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            fontDataContent = fontDataContent.Split(new[] { "$mdi-icons: (" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace(" ", "").Replace("\n", "").Replace(");", "").Replace("\"", "");

            string[] splitContent = fontDataContent.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < splitContent.Length; i++)
            {
                string[] splitLine = splitContent[i].Split(':');
                vectorImageSet.iconGlyphList.Add(new Glyph(splitLine[0], splitLine[1].ToLower(), false));
            }

            return(vectorImageSet);
        }
        public VectorImageSet GetIconSet()
        {
            if (!IsFontAvailable())
            {
                throw new Exception("Can't get the icon set because the font has not been downloaded");
            }

                        #if UNITY_5_2
            string iconFontData = File.ReadAllText(GetIconFontDataPath());
            iconFontData = iconFontData.Replace("m_Name", "name").Replace("m_Unicode", "unicode").Replace("m_IconGlyphList", "iconGlyphList");
            VectorImageSet vectorImageSet = JsonMapper.ToObject <VectorImageSet>(iconFontData);
                        #else
            VectorImageSet vectorImageSet = JsonUtility.FromJson <VectorImageSet>(File.ReadAllText(GetIconFontDataPath()));
                        #endif

            return(vectorImageSet);
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                string[] lineData = line.Split(' ');
                string   iconname = lineData[0];
                string   unicode  = lineData[1];

                vectorImageSet.iconGlyphList.Add(new Glyph(iconname, unicode, false));
            }

            GenerateIconEnum(vectorImageSet.iconGlyphList);

            return(vectorImageSet);
        }
        private void UpdateFontPackInfo()
        {
            string name = m_VectorImageDatas[0].font.name;
            m_VectorImageSet = VectorImageManager.GetIconSet(name);
            m_IconFont = VectorImageManager.GetIconFont(name);
            m_GuiStyle = new GUIStyle { font = m_IconFont };
            m_GuiStyle.normal.textColor = Color.white;

            UpdateGlyphList();

            // Assign the very first icon of the imageSet if the glyph is null
            Glyph glyph = m_VectorImageSet.iconGlyphList.Where(x => x.name.Equals(m_VectorImageDatas[0].glyph.name) && x.unicode.Equals(m_VectorImageDatas[0].glyph.unicode.Replace("\\u", ""))).FirstOrDefault();
            if (glyph == null)
            {
                SetGlyph(0);
            }
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                string name = line.Substring(0, line.IndexOf("\"\\")).Trim();
                name = name.Replace("$icons:", string.Empty).Trim();

                string unicode = line.Substring(line.IndexOf("\"\\") + 2);
                unicode = unicode.Substring(0, unicode.IndexOf("\""));

                vectorImageSet.iconGlyphList.Add(new Glyph(name, unicode, false));
            }

            return(vectorImageSet);
        }
Exemplo n.º 14
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

            bool canStartReading = false;

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (!canStartReading)
                {
                    if (line.StartsWith("glyphs:"))
                    {
                        canStartReading = true;
                    }

                    continue;
                }

                if (line.Contains("css:"))
                {
                    currentGlyph = new Glyph();

                    string name = line.Substring(line.IndexOf("css:") + 5).Trim();
                    currentGlyph.name = name;
                }

                if (line.Contains("code:") && line.Contains("0x"))
                {
                    if (currentGlyph != null)
                    {
                        string unicode = line.Substring(line.IndexOf("code:") + 6).Trim();
                        unicode = unicode.Replace("0x", string.Empty);
                        currentGlyph.unicode = unicode;

                        vectorImageSet.iconGlyphList.Add(currentGlyph);
                        currentGlyph = null;
                    }
                }
            }

            return(vectorImageSet);
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith(".oi[data-glyph") && line.Contains("content:"))
                {
                    string name = line.Replace(".oi[data-glyph=", string.Empty).Trim();
                    name = name.Substring(0, name.IndexOf("]")).Trim();

                    string unicode = line.Substring(line.IndexOf("content:'") + 10);
                    unicode = unicode.Substring(0, unicode.IndexOf("'; }"));

                    Glyph glyph = new Glyph(name, unicode, false);
                    vectorImageSet.iconGlyphList.Add(glyph);
                }
            }

            return(vectorImageSet);
        }
        private IEnumerator DownloadIconFontData()
        {
            WWW www = new WWW(GetIconFontDataUrl());

            while (!www.isDone)
            {
                yield return(null);
            }

            if (!string.IsNullOrEmpty(www.error))
            {
                ClearProgressBar();
                throw new Exception("Error downloading icon font data (" + GetFontName() + ") at path: " + GetIconFontDataUrl() + "\n" + www.error);
            }

            CreateFolderPath();

            VectorImageSet vectorImageSet = GenerateIconSet(www.text);

            FormatNames(vectorImageSet);

                        #if UNITY_5_2
            string codePointJson = JsonMapper.ToJson(vectorImageSet);
            codePointJson = codePointJson.Replace("name", "m_Name").Replace("unicode", "m_Unicode").Replace("iconGlyphList", "m_IconGlyphList");
                        #else
            string codePointJson = JsonUtility.ToJson(vectorImageSet);
                        #endif

            File.WriteAllText(GetIconFontDataPath(), codePointJson);

            if (m_OnDoneDownloading != null)
            {
                m_OnDoneDownloading();
            }

            CleanUp();

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Exemplo n.º 17
0
        public static string GetIconCodeFromName(string name, string setName = "*")
        {
            bool noPackSpecified = (setName == "*");

            if (noPackSpecified)
            {
                string[]         setNames = GetAllIconSetNames();
                VectorImageSet[] sets     = new VectorImageSet[setNames.Length];

                for (int i = 0; i < setNames.Length; i++)
                {
                    sets[i] = GetIconSet(setNames[i]);
                }

                for (int i = 0; i < sets.Length; i++)
                {
                    for (int j = 0; j < sets[i].iconGlyphList.Count; j++)
                    {
                        if (name == sets[i].iconGlyphList[j].name)
                        {
                            return(sets[i].iconGlyphList[j].unicode);
                        }
                    }
                }
            }
            else
            {
                VectorImageSet set = GetIconSet(setName);

                for (int j = 0; j < set.iconGlyphList.Count; j++)
                {
                    if (name == set.iconGlyphList[j].name)
                    {
                        return(set.iconGlyphList[j].unicode);
                    }
                }
            }
            return(null);
        }
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

            bool canStartReading = false;

            foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (!canStartReading)
                {
                    if (line.StartsWith(".ki-"))
                    {
                        canStartReading = true;
                    }
                    else
                    {
                        continue;
                    }
                }

                if (line.Contains(".ki-"))
                {
                    Glyph currentGlyph = new Glyph();

                    string[] lineParts = line.Split(':');

                    currentGlyph.name = lineParts[0].Replace(".ki-", "");

                    currentGlyph.unicode = lineParts[2].Replace(" ", "").Replace("\"", "").Replace("\\", "").Replace(";}", "");

                    vectorImageSet.iconGlyphList.Add(currentGlyph);
                }
            }

            return(vectorImageSet);
        }