예제 #1
0
파일: BMFont.cs 프로젝트: codecat/mrag2
        /// <summary>
        /// Load a BMFont from a stream, and a single page. This page will be used as the first page. More pages can be added manually.
        /// </summary>
        /// <param name="streamXml">The stream for the XML.</param>
        /// <param name="texturePage">The singular (or just the first) texture page.</param>
        public BMFont(Stream streamXml, System.Drawing.Bitmap texturePage)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(BMFontModels.FontFile));
            TextReader    textReader   = new StreamReader(streamXml);

            m_font = (BMFontModels.FontFile)deserializer.Deserialize(textReader);
            textReader.Close();

            AddPage(ContentRegister.BitmapToTexture(texturePage, "_BMFont_ctor2_" + m_font.Pages[0].File));
        }
예제 #2
0
파일: BMFont.cs 프로젝트: codecat/mrag2
        /// <summary>
        /// Load a BMFont from a path to an XML-encoded .fnt file.
        /// </summary>
        /// <param name="filename">Path to the XML file.</param>
        public BMFont(string filename)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(BMFontModels.FontFile));
            TextReader    textReader   = new StreamReader(filename);

            m_font = (BMFontModels.FontFile)deserializer.Deserialize(textReader);
            textReader.Close();

            foreach (var page in m_font.Pages)
            {
                Texture2D texture = ContentRegister.Texture(System.IO.Path.GetDirectoryName(filename) + "/" + page.File);
                Debug.Assert(texture != null);
                AddPage(texture);
            }
        }