public C2DFont LoadFont(string name, string metrics)
        {
            if ((name == null) || (metrics == null))
            {
                return(null);
            }
            C2DImage img = GetImage(name);

            if (img == null)
            {
                return(null);
            }
            // string metrics = global::UV_DLP_3D_Printer.Properties.Resources.ResourceManager.GetString(name + "_metrics");
            try
            {
                MemoryStream ms   = new MemoryStream(Encoding.UTF8.GetBytes(metrics));
                XmlDocument  xdoc = new XmlDocument();
                xdoc.Load(ms);
                XmlNode rootnode = xdoc.ChildNodes[1];
                if (rootnode.Name != "fontMetrics")
                {
                    return(null);
                }

                C2DFont font = new C2DFont();
                font.image = img;
                font.chars = new C2DChar[256];
                for (int i = 0; i < 256; i++)
                {
                    font.chars[0] = null;
                }
                C2DChar chr = null;
                int     chrnum;

                foreach (XmlNode xnode in rootnode.ChildNodes)
                {
                    chrnum             = int.Parse(xnode.Attributes["key"].Value);
                    chr                = new C2DChar();
                    chr.x              = int.Parse(xnode["x"].InnerText);
                    chr.y              = int.Parse(xnode["y"].InnerText);
                    chr.w              = int.Parse(xnode["width"].InnerText);
                    chr.h              = int.Parse(xnode["height"].InnerText);
                    font.chars[chrnum] = chr;
                }
                if (chr != null)
                {
                    font.height = chr.h;
                }
                FontDbase[name] = font;
                return(font);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public void Text(C2DFont fnt, float x, float y, string text)
        {
            C2DChar chr = null;

            foreach (char ch in text)
            {
                if ((ch > 255) || (fnt.chars[ch] == null))
                {
                    continue;
                }
                chr = fnt.chars[ch];
                Image(fnt.image, chr.x, chr.y, chr.w, chr.h, x, y, chr.w, chr.h);
                x += chr.w;
            }
        }
        public C2DFont LoadFont(string name, string metrics)
        {
            if ((name == null) || (metrics == null))
                return null;
            C2DImage img = GetImage(name);
            if (img == null)
                return null;
            // string metrics = global::UV_DLP_3D_Printer.Properties.Resources.ResourceManager.GetString(name + "_metrics");
            try
            {
                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(metrics));
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(ms);
                XmlNode rootnode = xdoc.ChildNodes[1];
                if (rootnode.Name != "fontMetrics")
                    return null;

                C2DFont font = new C2DFont();
                font.image = img;
                font.chars = new C2DChar[256];
                for (int i = 0; i < 256; i++)
                    font.chars[0] = null;
                C2DChar chr = null;
                int chrnum;

                foreach (XmlNode xnode in rootnode.ChildNodes)
                {
                    chrnum = int.Parse(xnode.Attributes["key"].Value);
                    chr = new C2DChar();
                    chr.x = int.Parse(xnode["x"].InnerText);
                    chr.y = int.Parse(xnode["y"].InnerText);
                    chr.w = int.Parse(xnode["width"].InnerText);
                    chr.h = int.Parse(xnode["height"].InnerText);
                    font.chars[chrnum] = chr;
                }
                if (chr != null)
                    font.height = chr.h;
                FontDbase[name] = font;
                return font;
            }
            catch (Exception)
            {
                return null;
            }
        }