Пример #1
0
        /// <summary>
        /// Loads a bitmap font from a file containing font data in XML format.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <exception cref="FileNotFoundException">Thrown when the requested file is not present.</exception>
        /// <param name="filename">Name of the file to load.</param>
        /// <returns>
        /// A <see cref="BitmapFont"/> containing the loaded data.
        /// </returns>
        public static BitmapFont LoadFontFromXmlFile(string filename)
        {
            var font = new BitmapFont();

            using (var stream = TitleContainer.OpenStream(filename))
                font.LoadXml(stream);

            QualifyResourcePaths(font, Path.GetDirectoryName(filename));
            font.Initialize();

            return(font);
        }
Пример #2
0
        /// <summary>
        /// Loads a bitmap font from a file containing font data in text format.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <exception cref="FileNotFoundException">Thrown when the requested file is not present.</exception>
        /// <param name="filename">Name of the file to load.</param>
        /// <returns>
        /// A <see cref="BitmapFont"/> containing the loaded data.
        /// </returns>
        public static BitmapFont LoadFontFromTextFile(string filename, bool premultiplyAlpha = false)
        {
            var font = new BitmapFont();

            using (var stream = TitleContainer.OpenStream(filename))
                font.LoadText(stream);

            QualifyResourcePaths(font, Path.GetDirectoryName(filename));
            font.Initialize(premultiplyAlpha);

            return(font);
        }