Ejemplo n.º 1
0
        public static VectorImageSet GenerateSpecificIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

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

                    string name = line.Replace(".icon-", string.Empty).Trim();
                    name = name.Substring(0, name.IndexOf(":")).Trim();

                    currentGlyph.name = name;
                }

                if (line.StartsWith("  content:"))
                {
                    if (currentGlyph != null)
                    {
                        string unicode = line.Substring(line.IndexOf("content:") + 10);
                        unicode = unicode.Substring(0, unicode.IndexOf("\";"));
                        unicode = ((int)unicode[0]).ToString("X4");
                        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("    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;
		}
        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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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();
			Glyph currentGlyph = null;
			
			foreach (string line in fontDataContent.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
			{
				if (line.StartsWith(".icon-") && line.Contains(":before"))
				{
					currentGlyph = new Glyph();

					string name = line.Replace(".icon-", string.Empty).Trim();
					name = name.Substring(0, name.IndexOf(":")).Trim();

					currentGlyph.name = name;
				}

				if (line.StartsWith("  content:"))
				{
					if (currentGlyph != null)
					{
						string unicode = line.Substring(line.IndexOf("content:") + 10);
						unicode = unicode.Substring(0, unicode.IndexOf("\";"));
						unicode = ((int)unicode[0]).ToString("X4");

						currentGlyph.unicode = unicode;

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

            return vectorImageSet;
		}
Ejemplo n.º 8
0
        public static VectorImageSet GenerateSpecificIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            Glyph          currentGlyph   = null;

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

                    if (intcode < 1000)
                    {
                        currentGlyph = null;
                        continue;
                    }

                    currentGlyph.unicode = intcode.ToString("X4");
                }

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

            return(vectorImageSet);
        }
        public static VectorImageSet GenerateSpecificIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();
            //Glyph currentGlyph = null;
            // Pattern to Match
            // icon-my-icon-name:before {
            //    content: "\5a"; }
            var pattern = @"icon-(.*):before[\n ]*{[\n ]*content:[ '""\\]+([0-9a-fA-F]+)['"";]+";
            var matches = System.Text.RegularExpressions.Regex.Matches(fontDataContent, pattern);

            foreach (System.Text.RegularExpressions.Match match in matches)
            {
                if (match.Groups.Count >= 3)
                {
                    var currentGlyph = new Glyph();
                    currentGlyph.name = match.Groups[1].ToString();

                    //Now convert to hex X4 format
                    var hexUnicode = match.Groups[2].ToString();
                    int intUnicode = 0;
                    int.TryParse(hexUnicode, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out intUnicode);
                    currentGlyph.unicode = intUnicode.ToString("X4").ToLower();

                    //add to ImageSet
                    vectorImageSet.iconGlyphList.Add(currentGlyph);
                }
            }

            return(vectorImageSet);
        }
Ejemplo n.º 10
0
        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);

            string codePointJson = JsonUtility.ToJson(vectorImageSet);

            File.WriteAllText(GetIconFontDataPath(), codePointJson);

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

            CleanUp();

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Ejemplo n.º 11
0
        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;
        }
		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;
		}
        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);
        }
		public static VectorImageSet GenerateSpecificIconSet(string fontDataContent)
		{
			VectorImageSet vectorImageSet = new VectorImageSet();
			Glyph currentGlyph = null;

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

					if (intcode < 1000)
					{
						currentGlyph = null;
						continue;
					}

                    currentGlyph.unicode = intcode.ToString("X4");
				}
				
				if (line.StartsWith("				\"name\":"))
				{
					if (currentGlyph != null)
					{
                        currentGlyph.name = line.Substring(line.IndexOf(":") + 1).Replace(",", "").Replace("\"", "").Trim();
                        vectorImageSet.iconGlyphList.Add(currentGlyph);
						currentGlyph = null;
					}
				}
			}

			return vectorImageSet;
		}
Ejemplo n.º 15
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("            <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);
        }
Ejemplo n.º 16
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            var   vectorImageSet = new VectorImageSet();
            Glyph currentGlyph   = null;

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

                    var name = line.Replace(".pw-", string.Empty).Trim();
                    name = name.Substring(0, name.IndexOf(":")).Trim();

                    currentGlyph.name = name;
                }

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

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

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

            Regex getIconData = new Regex("\".*?\":.*?(}.*?}.*?},)", RegexOptions.Singleline);
            Regex getStyles   = new Regex("(?<=\"styles\":\\s\\[).*?(?=\\])", RegexOptions.Singleline);
            Regex getUnicode  = new Regex("(?<=\"unicode\":\\s\").*?(?=\")", RegexOptions.Singleline);
            Regex getLabel    = new Regex("(?<=\"label\":\\s\").*?(?=\")", RegexOptions.Singleline);

            foreach (Match iconData in getIconData.Matches(fontDataContent))
            {
                bool hasStyle = false;

                foreach (Match style in getStyles.Matches(iconData.Value))
                {
                    if (style.Value.Contains(styleToMatch))
                    {
                        hasStyle = true;
                        break;
                    }
                }

                if (hasStyle)
                {
                    vectorImageSet.iconGlyphList.Add(new Glyph()
                    {
                        name    = getLabel.Match(iconData.Value).Value,
                        unicode = getUnicode.Match(iconData.Value).Value
                    });
                }
            }

            return(vectorImageSet);
        }
Ejemplo n.º 18
0
        public VectorImageSet GetCachedIconSet()
        {
            if (m_CachedVectorImageSet == null)
            {
                m_CachedVectorImageSet = GetIconSet();
            }

            return(m_CachedVectorImageSet);
        }
Ejemplo n.º 19
0
        public VectorImageSet GetIconSet()
        {
            if (!IsFontAvailable())
            {
                throw new Exception("Can't get the icon set because the font has not been downloaded");
            }

            VectorImageSet vectorImageSet = JsonUtility.FromJson <VectorImageSet>(File.ReadAllText(GetIconFontDataPath()));

            return(vectorImageSet);
        }
Ejemplo n.º 20
0
		static MaterialIconHelper()
		{
			if (m_Font == null)
			{
				m_Font = VectorImageManager.GetIconFont(VectorImageManager.materialDesignIconsFontName);
			}
			
			if (m_IconSet == null)
			{
				m_IconSet = VectorImageManager.GetIconSet(VectorImageManager.materialDesignIconsFontName);
			}
		}
Ejemplo n.º 21
0
        static MaterialUIIconHelper()
        {
            if (m_Font == null)
            {
                m_Font = VectorImageManager.GetIconFont(VectorImageManager.materialUIIconsFontName);
            }

            if (m_IconSet == null)
            {
                m_IconSet = VectorImageManager.GetIconSet(VectorImageManager.materialUIIconsFontName);
            }
        }
Ejemplo n.º 22
0
        public static ImageData GetIcon(string set, MaterialIconEnum name)
        {
            VectorImageSet iconSet = VectorImageManager.GetIconSet(set);
            Glyph          glyph   = iconSet.iconGlyphList.FirstOrDefault(x => x.name.ToLower().Equals(name.ToString().ToLower()));
            Font           font    = VectorImageManager.GetIconFont(set);

            if (glyph == null)
            {
                Debug.LogError("Could not find an icon with the name: " + name + " inside the MaterialDesign icon font");
                return(null);
            }
            return(new ImageData(new VectorImageData(glyph, font)));
        }
        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);
        }
Ejemplo n.º 24
0
        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();

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

            string[] lineOne = splitContent[0].Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries);
            string[] lineTwo = splitContent[1].Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 1; i < lineOne.Length; i++)
            {
                vectorImageSet.iconGlyphList.Add(new Glyph(lineTwo[i].Replace("'", ""), lineOne[i].Replace("'", ""), false));
            }

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

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

		    string[] lineOne = splitContent[0].Split(new []{" "}, StringSplitOptions.RemoveEmptyEntries);
		    string[] lineTwo = splitContent[1].Split(new []{" "}, StringSplitOptions.RemoveEmptyEntries);

		    for (int i = 1; i < lineOne.Length; i++)
		    {
		        vectorImageSet.iconGlyphList.Add(new Glyph(lineTwo[i].Replace("'", ""), lineOne[i].Replace("'", ""), false));
            }

            return vectorImageSet;
		}
        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);
        }
Ejemplo n.º 28
0
        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);
        }
		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;
		}
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            var   vectorImageSet = new VectorImageSet();
            Glyph currentGlyph   = null;

            var canStartReading = false;

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

                    continue;
                }

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

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

                if (line.Contains("code:") && line.Contains("0x"))
                {
                    if (currentGlyph != null)
                    {
                        var 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();

            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));
            }

            return(vectorImageSet);
        }
		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[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (line.StartsWith(".octicon-") && line.Contains("content:"))
                {
                    string name = line.Replace(".octicon-", string.Empty).Trim();
                    name = name.Split(new[] { ":" }, StringSplitOptions.None)[0];

                    string unicode = line.Split(new[] { "\"" }, StringSplitOptions.None)[1].Replace("\\", "");

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

            return(vectorImageSet);
        }
Ejemplo n.º 35
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            var vectorImageSet = new VectorImageSet();

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

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

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

            return(vectorImageSet);
        }
Ejemplo n.º 36
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            VectorImageSet vectorImageSet = new VectorImageSet();

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

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

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

            return(vectorImageSet);
        }
        private void UpdateFontPackInfo()
        {
            string name = m_VectorImageData.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_VectorImageData.glyph.name) && x.unicode.Equals(m_VectorImageData.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))
			{
				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;
		}
Ejemplo n.º 39
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);
        }
Ejemplo n.º 40
0
        protected override VectorImageSet GenerateIconSet(string fontDataContent)
        {
            var vectorImageSet = new VectorImageSet();

            var canStartReading = false;

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

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

                    var lineParts = line.Split(':');

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

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

                    vectorImageSet.iconGlyphList.Add(currentGlyph);
                }
            }

            return(vectorImageSet);
        }
Ejemplo n.º 41
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;
        }
Ejemplo n.º 42
0
        protected virtual void RecreateIconSet()
        {
            m_IconSet = new VectorImageSet();
            var v_needAutoCreate = true;

            try
            {
                if (m_ImageSetTextAsset != null)
                {
                    JsonUtility.FromJsonOverwrite(m_ImageSetTextAsset.text, m_IconSet);
                    v_needAutoCreate = false;
                }
            }
            catch { }

            if (v_needAutoCreate)
            {
                if (m_Font != null)
                {
                    CharacterInfo[] v_charInfos = PickAllCharInfos(m_Font);
                    foreach (var v_charInfo in v_charInfos)
                    {
                        var unicode = v_charInfo.index.ToString();
                        if (!unicode.StartsWith(@"\u"))
                        {
                            unicode = @"\u" + unicode;
                        }

                        m_IconSet.iconGlyphList.Add(new Glyph(unicode, unicode, true));
                    }
                }
                else if (m_FontTMPro != null)
                {
                    HashSet <uint>       v_addedGlyphs       = new HashSet <uint>();
                    List <TMP_FontAsset> v_fontsToCheckIcons = new List <TMP_FontAsset>();
                    v_fontsToCheckIcons.Add(m_FontTMPro);

                    for (int i = 0; i < v_fontsToCheckIcons.Count; i++)
                    {
                        var currentFont = v_fontsToCheckIcons[i];
#if UNITY_2018_3_OR_NEWER
                        foreach (var v_pair in currentFont.characterLookupTable)
#else
                        foreach (var v_pair in currentFont.characterDictionary)
#endif
                        {
                            var keyUInt = (uint)v_pair.Key;
                            if (!v_addedGlyphs.Contains(keyUInt))
                            {
                                v_addedGlyphs.Add(keyUInt);
                                var unicode = v_pair.Key.ToString();
                                if (!unicode.StartsWith(@"\u"))
                                {
                                    unicode = @"\u" + unicode;
                                }

                                m_IconSet.iconGlyphList.Add(new Glyph(unicode, unicode, true));
                            }
                        }
#if UNITY_2018_3_OR_NEWER
                        foreach (var v_fallbackFont in currentFont.fallbackFontAssetTable)
#else
                        foreach (var v_fallbackFont in currentFont.fallbackFontAssets)
#endif
                        {
                            if (v_fallbackFont != null && !v_fontsToCheckIcons.Contains(v_fallbackFont))
                            {
                                v_fontsToCheckIcons.Add(v_fallbackFont);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 43
0
        private void UpdateFontPackInfo()
        {
            string name = m_VectorImageData.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_VectorImageData.glyph.name) && x.unicode.Equals(m_VectorImageData.glyph.unicode.Replace("\\u", ""))).FirstOrDefault();
			if (glyph == null)
			{
				SetGlyph(0);
			}
        }