Ejemplo n.º 1
0
        public static void LoadxFont()
        {
            Dictionary <string, Font2Font> isLoaded = new Dictionary <string, Font2Font>();

            FontList = new Dictionary <string, Font2Font>();
            XmlDocument doc = new XmlDocument();

            doc.Load(File.OpenRead("GameData/DTS_zh/zhFont.xml"));
            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (!(node is XmlElement))
                {
                    continue;
                }
                XmlElement item = (XmlElement)node;

                if (isLoaded.ContainsKey(item.InnerText))
                {//找到已经加载的文件就不用再次加载了,重复加载会出现异常
                    FontList.Add(item.GetAttribute("name"), isLoaded[item.InnerText]);
                }
                else
                {
                    Font2Font font = new Font2Font();
                    font.Load(item.InnerText);
                    isLoaded.Add(item.InnerText, font);

                    FontList.Add(item.GetAttribute("name"), font);
                }
                Debug.LogWarning("xFont:载入" + item.GetAttribute("name") + "==" + item.InnerText);
            }
            Debug.LogWarning("xFont:载入" + FontList.Count.ToString());
        }
Ejemplo n.º 2
0
        public bool SetSpriteTextRichFont(SpriteTextRich ST)
        {
            bool result = false;

            if (FontList.Count == 0)
            {
                LoadxFont();
            }
            // if (ST.font.name[0] == 'c' && ST.font.name[1] == 'n') return result;

            //Debug.Log("[xFont2-1]" + ST.font.name + " :: " + ST.text);
            for (int i = 0; i < ST.font.fonts.Length; i++)
            {
                if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n')
                {
                    continue;
                }

                Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name);
                Debug.Log("[xFont2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                ST.font.fonts[i].fontText   = f2f.fontDef;
                ST.font.fonts[i].material   = f2f.fontMat;
                ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef);
                //Debug.Log("[xFont2-2]" + ST.font.name + "-->>" + f2f.Name + " :: " + ST.text);
                result = true;
            }
            ST.font.name = "cn" + ST.font.name;
            return(result);
        }
Ejemplo n.º 3
0
        public static void LoadxFont()
        {
            Dictionary<string, Font2Font> isLoaded = new Dictionary<string, Font2Font>();
            FontList = new Dictionary<string, Font2Font>();
            XmlDocument doc = new XmlDocument();
            doc.Load(File.OpenRead("GameData/DTS_zh/zhFont.xml"));
            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (!(node is XmlElement)) continue;
                XmlElement item = (XmlElement)node;

                if (isLoaded.ContainsKey(item.InnerText))
                {//找到已经加载的文件就不用再次加载了,重复加载会出现异常
                    FontList.Add(item.GetAttribute("name"), isLoaded[item.InnerText]);
                }
                else
                {
                    Font2Font font = new Font2Font();
                    font.Load(item.InnerText);
                    isLoaded.Add(item.InnerText, font);

                    FontList.Add(item.GetAttribute("name"), font);
                }
                Debug.LogWarning("xFont:载入" + item.GetAttribute("name") + "==" + item.InnerText);
            }
            Debug.LogWarning("xFont:载入" + FontList.Count.ToString());
        }
Ejemplo n.º 4
0
        public void SetSpriteTextFont(SpriteText ST)
        {
            if (FontList.Count == 0)
            {
                LoadxFont();
            }
            //Debug.LogWarning("xFont:" + ST.font.name + "-->>");

            if (ST.font.name[0] == 'c' && ST.font.name[1] == 'n')
            {
                return;
            }
            Font2Font f2f = GetFont2Font(ST.font.name);

            Debug.Log("[xFont1]" + ST.font.name + "-->>" + f2f.Name + ST.text);
            ST.SetFont(f2f.fontDef, f2f.fontMat);
        }
Ejemplo n.º 5
0
        public void SetSpriteTextRichFont(SpriteTextRich ST)
        {
            if (FontList.Count == 0)
            {
                LoadxFont();
            }

            for (int i = 0; i < ST.font.fonts.Length; i++)
            {
                if (ST.font.fonts[i].fontText.name[0] == 'c' && ST.font.fonts[i].fontText.name[1] == 'n')
                {
                    return;
                }

                Font2Font f2f = GetFont2Font(ST.font.fonts[i].fontText.name);
                Debug.Log("xFont:" + ST.font.name + "-->>" + f2f.Name);
                ST.font.fonts[i].fontText   = f2f.fontDef;
                ST.font.fonts[i].material   = f2f.fontMat;
                ST.font.fonts[i].SpriteFont = FontStore.GetFont(f2f.fontDef);
            }
        }