/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a font object with the specified properties. If an error occurs while /// making the font (e.g. because the font doesn't support a particular style) a /// fallback scheme is used. /// </summary> /// ------------------------------------------------------------------------------------ public static Font MakeFont(string fontName, float size, FontStyle style) { try { var family = FontFamily.Families.SingleOrDefault(f => f.Name == fontName); if (family != null) { if (family.IsStyleAvailable(style)) { return(new Font(family, size, style, GraphicsUnit.Point)); } for (style = (FontStyle)0; (int)style <= 3; style = (FontStyle)(int)style + 1) { if (family.IsStyleAvailable(style)) { return(new Font(family, size, style, GraphicsUnit.Point)); } } } } catch { } return((Font)UIFont.Clone()); }