ComponentFactory.Krypton.Toolkit.RenderStandard.ContentFontForButtonForm C# (CSharp) Method

ContentFontForButtonForm() private static method

private static ContentFontForButtonForm ( ViewLayoutContext context, Font font ) : Font
context ViewLayoutContext
font System.Drawing.Font
return System.Drawing.Font
        private static Font ContentFontForButtonForm(ViewLayoutContext context,
                                                     Font font)
        {
            // Get the krypton form that contains this control
            KryptonForm kryptonForm = OwningKryptonForm(context.TopControl);

            // Not interested if not inside a krypton form
            if (kryptonForm != null)
            {
                // Get the padding just for the chrome borders
                Padding chromeBorders = kryptonForm.RealWindowBorders;

                // How much space is available for the font
                int fontSpace = chromeBorders.Top - 6;

                // If not enough room for the font then create a new smaller font
                if ((font.Height > fontSpace) && (fontSpace > 5))
                {
                    // Find the point size from the pixel height required
                    float point = 72 / context.Graphics.DpiY * (fontSpace / 1.333f);

                    // No point having a font smaller than 3 points
                    if (point > 3)
                        font = new Font(font.FontFamily, point, font.Style);
                }
            }

            return font;
        }
RenderStandard