using System; using System.Drawing; using System.Windows.Forms; class FontMenuForm: Form { protected string strText = "Emboss"; protected Font font = new Font("Times New Roman", 24); public static void Main() { Application.Run(new FontMenuForm()); } public FontMenuForm() { ResizeRedraw = true; } protected void DoPage(Graphics grfx, Color clr, int cx, int cy) { int iOffset = 2; SizeF sizef = grfx.MeasureString(strText, font); float x = (cx - sizef.Width) / 2; float y = (cy - sizef.Height) / 2; grfx.Clear(Color.White); grfx.DrawString(strText, font, Brushes.Gray, x, y); grfx.DrawString(strText, font, Brushes.White, x - iOffset, y - iOffset); } public float GetAscent(Graphics grfx, Font font) { return font.GetHeight(grfx) * font.FontFamily.GetCellAscent(font.Style) / font.FontFamily.GetLineSpacing(font.Style); } public float GetDescent(Graphics grfx, Font font) { return font.GetHeight(grfx) * font.FontFamily.GetCellDescent(font.Style) / font.FontFamily.GetLineSpacing(font.Style); } public float PointsToPageUnits(Graphics grfx, Font font) { float fFontSize; if (grfx.PageUnit == GraphicsUnit.Display) fFontSize = 100 * font.SizeInPoints / 72; else fFontSize = grfx.DpiX * font.SizeInPoints / 72; return fFontSize; } }