示例#1
0
        /// <summary>
        /// Compiles the specified font description into a <see cref="SignedDistanceFieldSpriteFont" /> object.
        /// </summary>
        /// <param name="fontFactory">The font factory used to create the fonts</param>
        /// <param name="fontAsset">The font description.</param>
        /// <returns>A SpriteFontData object.</returns>
        public static Graphics.SpriteFont Compile(IFontFactory fontFactory, SpriteFontAsset fontAsset)
        {
            if (fontAsset.FontType != SpriteFontType.SDF)
            {
                throw new ArgumentException("Tried to compile an incompatible sprite font with compiler for scalable fonts");
            }

            float lineSpacing;
            float baseLine;

            var glyphs = ImportFont(fontAsset, out lineSpacing, out baseLine);

            Bitmap bitmap = GlyphPacker.ArrangeGlyphs(glyphs);

            return(SignedDistanceFieldFontWriter.CreateSpriteFontData(fontFactory, fontAsset, glyphs, lineSpacing, baseLine, bitmap));
        }
示例#2
0
        /// <summary>
        /// Compiles the specified font description into a <see cref="SignedDistanceFieldSpriteFont" /> object.
        /// </summary>
        /// <param name="fontFactory">The font factory used to create the fonts</param>
        /// <param name="fontAsset">The font description.</param>
        /// <returns>A SpriteFontData object.</returns>
        public static Graphics.SpriteFont Compile(IFontFactory fontFactory, SpriteFontAsset fontAsset)
        {
            var fontTypeSDF = fontAsset.FontType as SignedDistanceFieldSpriteFontType;

            if (fontTypeSDF == null)
            {
                throw new ArgumentException("Tried to compile a dynamic sprite font with compiler for signed distance field fonts");
            }

            float lineSpacing;
            float baseLine;

            var glyphs = ImportFont(fontAsset, out lineSpacing, out baseLine);

            Bitmap bitmap = GlyphPacker.ArrangeGlyphs(glyphs);

            return(SignedDistanceFieldFontWriter.CreateSpriteFontData(fontFactory, fontAsset, glyphs, lineSpacing, baseLine, bitmap));
        }