public static SizeF GetGlyphBatchedSprites(
     this BitmapFont font, ICollection <GlyphBatchedSprite> output, string text, Vector2 position, Color color,
     float rotation, Vector2 origin, Vector2?scale, float depth, RectangleF?clipRect)
 {
     using (var glyphs = (GlyphEnumerator)font.GetGlyphs(text, position))
         return(GetGlyphBatchedSprites(glyphs, output, position, color, rotation, origin, scale, depth, clipRect));
 }
        public static void DrawString(
            this SpriteBatch spriteBatch, BitmapFont font, StringBuilder text, Vector2 position, Color color,
            float rotation, Vector2 origin, Vector2 scale, SpriteEffects effect, float layerDepth, RectangleF?clippingRectangle = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            ThrowOnArgs(effect);

            using (var glyphs = font.GetGlyphs(text, position))
                DrawString(spriteBatch, glyphs, position, color, rotation, origin, scale, layerDepth, clippingRectangle);
        }
        public static void DrawString(this SpriteBatch spriteBatch, BitmapFont bitmapFont, StringBuilder text, Vector2 position,
                                      Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effect, float layerDepth, Rectangle?clippingRectangle = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (effect != SpriteEffects.None)
            {
                throw new NotSupportedException($"{effect} is not currently supported for {nameof(BitmapFont)}");
            }

            var glyphs = bitmapFont.GetGlyphs(text, position);

            foreach (var glyph in glyphs)
            {
                if (glyph.FontRegion == null)
                {
                    continue;
                }
                var characterOrigin = position - glyph.Position + origin;
                spriteBatch.Draw(glyph.FontRegion.TextureRegion, position, color, rotation, characterOrigin, scale, effect, layerDepth, clippingRectangle);
            }
        }