/// <summary>
        /// Generate font textures for the given glyphs.
        /// </summary>
        /// <param name="adjustedGlyphs">The enumeration of adjusted glyphs.</param>
        /// <param name="textureCount">The maximum texture count.</param>
        /// <returns>The generated textures.</returns>
        public Bitmap[] GenerateFontTextures(List <AdjustedGlyph> adjustedGlyphs, int textureCount = -1)
        {
            var fontTextures = new List <Bitmap>(textureCount >= 0 ? textureCount : 0);

            var remainingAdjustedGlyphs = adjustedGlyphs;

            while (remainingAdjustedGlyphs.Count > 0)
            {
                // Stop if the texture limit is reached
                if (textureCount >= 0 && fontTextures.Count >= textureCount)
                {
                    break;
                }

                // Create new font texture to draw on.
                var fontTexture  = new Bitmap(CanvasSize.Width, CanvasSize.Height);
                var fontGraphics = Graphics.FromImage(fontTexture);

                fontTextures.Add(fontTexture);

                // Draw each positioned glyph on the font texture
                var handledGlyphs = new List <AdjustedGlyph>(adjustedGlyphs.Count);
                foreach (var positionedGlyph in _binPacker.Pack(adjustedGlyphs))
                {
                    DrawGlyph(fontGraphics, positionedGlyph);
                    handledGlyphs.Add(positionedGlyph.adjustedGlyph);
                }

                // Remove every handled glyph
                remainingAdjustedGlyphs = remainingAdjustedGlyphs.Except(handledGlyphs).ToList();
            }

            return(fontTextures.ToArray());
        }
        /// <summary>
        /// Generate font textures for the given glyphs.
        /// </summary>
        /// <param name="adjustedGlyphs">The enumeration of adjusted glyphs.</param>
        /// <param name="textureCount">The maximum texture count.</param>
        /// <returns>The generated textures.</returns>
        public IList <FontTextureInfo> GenerateFontTextures(IList <AdjustedGlyph> adjustedGlyphs, int textureCount = -1)
        {
            var fontTextures = new List <FontTextureInfo>(textureCount >= 0 ? textureCount : 0);

            var remainingAdjustedGlyphs = adjustedGlyphs;

            while (remainingAdjustedGlyphs.Count > 0)
            {
                // Stop if the texture limit is reached
                if (textureCount > 0 && fontTextures.Count >= textureCount)
                {
                    break;
                }

                // Create new font texture to draw on.
                var fontTexture  = new Bitmap(CanvasSize.Width, CanvasSize.Height);
                var fontGraphics = Graphics.FromImage(fontTexture);

                // Draw each positioned glyph on the font texture
                var handledGlyphs = new List <(AdjustedGlyph, Point)>(remainingAdjustedGlyphs.Count);
                foreach (var positionedGlyph in _binPacker.Pack(remainingAdjustedGlyphs))
                {
                    DrawGlyph(fontGraphics, positionedGlyph);
                    handledGlyphs.Add(positionedGlyph);
                }

                fontTextures.Add(new FontTextureInfo(fontTexture, handledGlyphs.Select(x => (x.Item1.Glyph, x.Item2)).ToList()));

                // Remove every handled glyph
                remainingAdjustedGlyphs = remainingAdjustedGlyphs.Except(handledGlyphs.Select(x => x.Item1)).ToList();
            }

            return(fontTextures);
        }