System.Windows.Forms.Control.DefaultFontから、コントロールの既定のフォントが取得できる。 System.Windows.Forms.SystemInformation.MenuFontからは、メニューに割り当てられるフォントが取得できる。
System.Drawing.Font fControl = System.Windows.Forms.Control.DefaultFont;
System.Drawing.Font fMenu = System.Windows.Forms.SystemInformation.MenuFont;
Console.WriteLine("システム フォント: " + fControl.ToString());
Console.WriteLine("メニュー フォント: " + fMenu.ToString());
Dim fControl As System.Drawing.Font = System.Windows.Forms.Control.DefaultFont
Dim fMenu As System.Drawing.Font = System.Windows.Forms.SystemInformation.MenuFont
Console.WriteLine("システム フォント: " + fControl.ToString())
Console.WriteLine("メニュー フォント: " + fMenu.ToString())
出力例
システム フォント: [Font: Name=MS UI Gothic, Size=9, Units=3, GdiCharSet=128, GdiVerticalFont=False] メニュー フォント: [Font: Name=Tahoma, Size=11, Units=0, GdiCharSet=1, GdiVerticalFont=False] Press any key to continue
ちなみに、System.Windows.Forms.SystemInformationクラスからは、システムに関する様々な情報を取得できる。