GetScaledFont() публичный Метод

public GetScaledFont ( float scaleRatio ) : Font
scaleRatio float
Результат System.Drawing.Font
Пример #1
0
        internal static SizeF GetTextSize(string text, FontDesc font, float fontScaling)
        {
            Graphics g = Util.GetHiresGraphics();
            using (Font f = font.GetScaledFont(fontScaling)) {
                SizeF size = g.MeasureString(text, f, new PointF(0, 0), StringFormat.GenericTypographic);

                // We really want the size of just the digits/capital letters. So, reduce by the descender size from
                // bottom and top (no way to get offset from top of box to top of cap letters).
                FontFamily family = f.FontFamily;
                float descender = family.GetCellDescent(f.Style) * font.EmHeight * fontScaling / family.GetEmHeight(f.Style);
                size.Height = size.Height - 2 * descender;

                return size;
            }
        }