Exemplo n.º 1
0
        /// <summary>
        /// Measure the whitespace of glyphs.
        /// </summary>
        /// <param name="glyphs">The glyphs to measure.</param>
        /// <returns>The measured glyphs.</returns>
        public static IEnumerable <AdjustedGlyph> MeasureWhiteSpace(IEnumerable <Bitmap> glyphs)
        {
            foreach (var glyph in glyphs)
            {
                var bitmapData = glyph.LockBits(new Rectangle(0, 0, glyph.Width, glyph.Height), ImageLockMode.ReadOnly,
                                                PixelFormat.Format32bppArgb);

                var top    = MeasureWhiteSpaceSide(0, bitmapData, glyph.Width, glyph.Height);
                var left   = MeasureWhiteSpaceSide(1, bitmapData, glyph.Width, glyph.Height);
                var bottom = MeasureWhiteSpaceSide(2, bitmapData, glyph.Width, glyph.Height);
                var right  = MeasureWhiteSpaceSide(3, bitmapData, glyph.Width, glyph.Height);

                glyph.UnlockBits(bitmapData);

                var adjustment = new WhiteSpaceAdjustment(
                    new Point(left, top),
                    new Size(glyph.Width - left - right, glyph.Height - top - bottom));
                yield return(new AdjustedGlyph(glyph, adjustment));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="AdjustedGlyph"/> with no adjustements to it.
 /// </summary>
 /// <param name="glyph">The glyph.</param>
 /// <param name="adjustment">The adjustments made to reduce white space in a glyph.</param>
 public AdjustedGlyph(Bitmap glyph, WhiteSpaceAdjustment adjustment)
 {
     WhiteSpaceAdjustment = adjustment;
     Glyph = glyph;
 }