CSharpGL.FontBitmapHelper.RetargetGlyphRectangleInwards C# (CSharp) Метод

RetargetGlyphRectangleInwards() приватный статический Метод

shrink glyph's width to fit in exactly.
private static RetargetGlyphRectangleInwards ( BitmapData bitmapData, GlyphInfo glyph ) : void
bitmapData BitmapData
glyph GlyphInfo
Результат void
        private static void RetargetGlyphRectangleInwards(BitmapData bitmapData, GlyphInfo glyph)
        {
            int startX, endX;

            {
                bool done = false;
                for (startX = glyph.xoffset; startX < bitmapData.Width; startX++)
                {
                    for (int j = glyph.yoffset; j < glyph.yoffset + glyph.height; j++)
                    {
                        if (!IsEmptyPixel(bitmapData, startX, j))
                        {
                            done = true;
                            break;
                        }
                    }
                    if (done) { break; }
                }
            }
            {
                bool done = false;
                for (endX = glyph.xoffset + glyph.width - 1; endX >= 0; endX--)
                {
                    for (int j = glyph.yoffset; j < glyph.yoffset + glyph.height; j++)
                    {
                        if (!IsEmptyPixel(bitmapData, endX, j))
                        {
                            done = true;
                            break;
                        }
                    }
                    if (done) { break; }
                }
            }

            if (endX < startX)
            {
                //startX = endX = glyph.xoffset;
                glyph.width = 0;
            }
            else
            {
                glyph.xoffset = startX;
                glyph.width = endX - startX + 1;
            }
        }