DutyContent/ThirdParty/FontUtilities.cs
ksh e59110cd2b
UI font setting (#18)
* UI font setting

* Fix detecting Bozja & Zadnor SK & CE

* update languages
2021-06-19 21:07:01 +09:00

29 lines
810 B
C#

using System.Drawing;
using System.Windows.Forms;
namespace DutyContent.ThirdParty
{
// https://www.codeproject.com/Questions/1080006/How-can-change-application-font-in-runtime
public static class FontUtilities
{
public static void SimpleChangeFont(Control ctrl, string fontname, bool recursive = false)
{
ctrl.Font = new Font(fontname, ctrl.Font.Size, ctrl.Font.Style, GraphicsUnit.Point);
if (recursive)
InternalRecursiveChangeFont(fontname, ctrl.Controls);
}
private static void InternalRecursiveChangeFont(string fontname, Control.ControlCollection ctrls)
{
foreach (Control c in ctrls)
{
c.Font = new Font(fontname, c.Font.Size, c.Font.Style, GraphicsUnit.Point);
if (c.Controls.Count > 0)
InternalRecursiveChangeFont(fontname, c.Controls);
}
}
}
}