--- mono-2.10.6-original/mcs/class/System.Drawing/System.Drawing/SystemFonts.cs +++ mono-2.10.6/mcs/class/System.Drawing/System.Drawing/SystemFonts.cs @@ -69,36 +69,55 @@ } public static Font CaptionFont { - get { return new Font ("Microsoft Sans Serif", 11, "CaptionFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "CaptionFont"); } } public static Font DefaultFont { - get { return new Font ("Microsoft Sans Serif", 8.25f, "DefaultFont"); } + get { return GetFont("Microsoft Sans Serif", 7.25f, "DefaultFont"); } } public static Font DialogFont { - get { return new Font ("Tahoma", 8, "DialogFont"); } + get { return GetFont("Tahoma", 8, "DialogFont"); } } public static Font IconTitleFont { - get { return new Font ("Microsoft Sans Serif", 11, "IconTitleFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "IconTitleFont"); } } public static Font MenuFont { - get { return new Font ("Microsoft Sans Serif", 11, "MenuFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "MenuFont"); } } public static Font MessageBoxFont { - get { return new Font ("Microsoft Sans Serif", 11, "MessageBoxFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "MessageBoxFont"); } } public static Font SmallCaptionFont { - get { return new Font ("Microsoft Sans Serif", 11, "SmallCaptionFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "SmallCaptionFont"); } } public static Font StatusFont { - get { return new Font ("Microsoft Sans Serif", 11, "StatusFont"); } + get { return GetFont("Microsoft Sans Serif", 11, "StatusFont"); } } + + private static Font GetFont(string fontName, float fontSize, string name) { + return new Font(GetFontName(name, fontName), GetFontSize(name, fontSize), name); + } + + private static String GetFontName(string name, string fallback) { + string font = Environment.GetEnvironmentVariable("MONO_" + name.ToUpper()); + return font == null ? fallback : font; + } + + private static float GetFontSize(string name, float fallback) { + string size = Environment.GetEnvironmentVariable("MONO_" + name.ToUpper() + "_SIZE"); + try { + return size == null ? fallback : (float) Convert.ToDouble(size); + } catch (System.Exception e) { + Console.Error.WriteLine(e); + return fallback; + } + } } }