* UIChart: 修复编辑器显示时出错的问题

This commit is contained in:
Sunny 2021-11-25 21:11:09 +08:00
parent 219e8a6498
commit db170d801b
11 changed files with 91 additions and 73 deletions

Binary file not shown.

Binary file not shown.

View File

@ -104,12 +104,10 @@
this.LineChart.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))); this.LineChart.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.LineChart.Font = new System.Drawing.Font("微软雅黑", 12F); this.LineChart.Font = new System.Drawing.Font("微软雅黑", 12F);
this.LineChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54))))); this.LineChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54)))));
this.LineChart.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LineChart.Location = new System.Drawing.Point(30, 55); this.LineChart.Location = new System.Drawing.Point(30, 55);
this.LineChart.MinimumSize = new System.Drawing.Size(1, 1); this.LineChart.MinimumSize = new System.Drawing.Size(1, 1);
this.LineChart.Name = "LineChart"; this.LineChart.Name = "LineChart";
this.LineChart.Size = new System.Drawing.Size(670, 430); this.LineChart.Size = new System.Drawing.Size(670, 430);
this.LineChart.SubFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LineChart.TabIndex = 35; this.LineChart.TabIndex = 35;
this.LineChart.Text = "uiLineChart1"; this.LineChart.Text = "uiLineChart1";
this.LineChart.PointValue += new Sunny.UI.UILineChart.OnPointValue(this.LineChart_PointValue); this.LineChart.PointValue += new Sunny.UI.UILineChart.OnPointValue(this.LineChart_PointValue);

View File

@ -44,13 +44,11 @@
this.PieChart.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))); this.PieChart.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
this.PieChart.Font = new System.Drawing.Font("微软雅黑", 12F); this.PieChart.Font = new System.Drawing.Font("微软雅黑", 12F);
this.PieChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54))))); this.PieChart.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(54)))), ((int)(((byte)(54)))));
this.PieChart.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PieChart.Location = new System.Drawing.Point(30, 55); this.PieChart.Location = new System.Drawing.Point(30, 55);
this.PieChart.MinimumSize = new System.Drawing.Size(1, 1); this.PieChart.MinimumSize = new System.Drawing.Size(1, 1);
this.PieChart.Name = "PieChart"; this.PieChart.Name = "PieChart";
this.PieChart.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None; this.PieChart.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None;
this.PieChart.Size = new System.Drawing.Size(670, 430); this.PieChart.Size = new System.Drawing.Size(670, 430);
this.PieChart.SubFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PieChart.TabIndex = 20; this.PieChart.TabIndex = 20;
this.PieChart.Text = "uiPieChart1"; this.PieChart.Text = "uiPieChart1";
// //

View File

@ -485,7 +485,7 @@ namespace Sunny.UI
} }
} }
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font,SubTextFontSize);
if (Option.XAxis.AxisLabel.Show) if (Option.XAxis.AxisLabel.Show)
{ {
@ -575,7 +575,7 @@ namespace Sunny.UI
g.DrawLine(pn, DrawOrigin.X, pos, Width - Option.Grid.Right, pos); g.DrawLine(pn, DrawOrigin.X, pos, Width - Option.Grid.Right, pos);
} }
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
SizeF sf = g.MeasureString(line.Name, tmp); SizeF sf = g.MeasureString(line.Name, tmp);
if (line.Left == UILeftAlignment.Left) if (line.Left == UILeftAlignment.Left)
@ -602,7 +602,7 @@ namespace Sunny.UI
for (int i = 0; i < Option.XAxis.Data.Count; i++) for (int i = 0; i < Option.XAxis.Data.Count; i++)
{ {
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
Bars[0][i].Size = g.MeasureString(Bars[0][i].Tips, tmp); Bars[0][i].Size = g.MeasureString(Bars[0][i].Tips, tmp);
} }
} }

View File

@ -453,6 +453,7 @@ namespace Sunny.UI
protected override void DrawSeries(Graphics g, List<UIBarSeries> series) protected override void DrawSeries(Graphics g, List<UIBarSeries> series)
{ {
if (series == null || series.Count == 0) return; if (series == null || series.Count == 0) return;
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
for (int i = 0; i < Bars.Count; i++) for (int i = 0; i < Bars.Count; i++)
{ {
@ -465,13 +466,13 @@ namespace Sunny.UI
{ {
if (s.BarName.Count > 0 && j < s.BarName.Count) if (s.BarName.Count > 0 && j < s.BarName.Count)
{ {
SizeF sf = g.MeasureString(s.BarName[j], SubFont); SizeF sf = g.MeasureString(s.BarName[j], tmp);
if (s.Data[j] >= 0) if (s.Data[j] >= 0)
g.DrawString(s.BarName[j], SubFont, ChartStyle.ForeColor, g.DrawString(s.BarName[j], tmp, ChartStyle.ForeColor,
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2, bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
bars[j].Rect.Bottom + 1); bars[j].Rect.Bottom + 1);
else else
g.DrawString(s.BarName[j], SubFont, ChartStyle.ForeColor, g.DrawString(s.BarName[j], tmp, ChartStyle.ForeColor,
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2, bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
bars[j].Rect.Top - sf.Height); bars[j].Rect.Top - sf.Height);
} }
@ -480,16 +481,16 @@ namespace Sunny.UI
if (s.ShowValue) if (s.ShowValue)
{ {
Font fontShow = null; Font fontShow = null;
if (s.ShowValueFontSize > 0) fontShow = new Font(SubFont.Name, s.ShowValueFontSize); if (s.ShowValueFontSize > 0) fontShow = new Font(tmp.Name, s.ShowValueFontSize);
string value = s.Data[j].ToString("F" + Option.YAxis.AxisLabel.DecimalCount); string value = s.Data[j].ToString("F" + Option.YAxis.AxisLabel.DecimalCount);
SizeF sf = g.MeasureString(value, fontShow ?? SubFont); SizeF sf = g.MeasureString(value, fontShow ?? tmp);
if (s.Data[j] < 0) if (s.Data[j] < 0)
g.DrawString(value, fontShow ?? SubFont, bars[j].Color, g.DrawString(value, fontShow ?? tmp, bars[j].Color,
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2, bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
bars[j].Rect.Bottom + 1); bars[j].Rect.Bottom + 1);
else else
g.DrawString(value, fontShow ?? SubFont, bars[j].Color, g.DrawString(value, fontShow ?? tmp, bars[j].Color,
bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2, bars[j].Rect.Left + bars[j].Rect.Width / 2 - sf.Width / 2,
bars[j].Rect.Top - sf.Height); bars[j].Rect.Top - sf.Height);
@ -500,7 +501,7 @@ namespace Sunny.UI
for (int i = 0; i < Option.Series.Count; i++) for (int i = 0; i < Option.Series.Count; i++)
{ {
Bars[i][0].Size = g.MeasureString(Bars[i][0].Tips, SubFont); Bars[i][0].Size = g.MeasureString(Bars[i][0].Tips, tmp);
} }
} }
@ -578,6 +579,7 @@ namespace Sunny.UI
} }
} }
using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
//绘制X轴标签 //绘制X轴标签
if (Option.XAxis.AxisLabel.Show) if (Option.XAxis.AxisLabel.Show)
{ {
@ -587,12 +589,12 @@ namespace Sunny.UI
foreach (var data in Option.Series) foreach (var data in Option.Series)
{ {
float w = DrawSize.Width * data.Data.Count * 1.0f / DataCount; float w = DrawSize.Width * data.Data.Count * 1.0f / DataCount;
SizeF sf = g.MeasureString(data.Name, SubFont); SizeF sf = g.MeasureString(data.Name, tmp);
if (Option.XAxis.AxisLabel.Angle != 0) if (Option.XAxis.AxisLabel.Angle != 0)
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, new PointF(start + w / 2.0f - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f), g.DrawString(data.Name, tmp, ChartStyle.ForeColor, new PointF(start + w / 2.0f - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360); new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
else else
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, start + w / 2.0f - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance); g.DrawString(data.Name, tmp, ChartStyle.ForeColor, start + w / 2.0f - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
start += w; start += w;
} }
} }
@ -601,18 +603,18 @@ namespace Sunny.UI
float start = DrawOrigin.X + DrawBarWidth / 2.0f; float start = DrawOrigin.X + DrawBarWidth / 2.0f;
foreach (var data in Option.Series) foreach (var data in Option.Series)
{ {
SizeF sf = g.MeasureString(data.Name, SubFont); SizeF sf = g.MeasureString(data.Name, tmp);
if (Option.XAxis.AxisLabel.Angle != 0) if (Option.XAxis.AxisLabel.Angle != 0)
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, new PointF(start - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f), g.DrawString(data.Name, tmp, ChartStyle.ForeColor, new PointF(start - 10, DrawOrigin.Y + Option.Grid.Bottom / 2.0f),
new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360); new StringFormat() { Alignment = StringAlignment.Center }, (3600 - Option.XAxis.AxisLabel.Angle) % 360);
else else
g.DrawString(data.Name, SubFont, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance); g.DrawString(data.Name, tmp, ChartStyle.ForeColor, start - sf.Width / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance);
start += DrawBarWidth; start += DrawBarWidth;
} }
} }
SizeF sfName = g.MeasureString(Option.XAxis.Name, SubFont); SizeF sfName = g.MeasureString(Option.XAxis.Name, tmp);
g.DrawString(Option.XAxis.Name, SubFont, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance + sfName.Height); g.DrawString(Option.XAxis.Name, tmp, ChartStyle.ForeColor, DrawOrigin.X + (DrawSize.Width - sfName.Width) / 2.0f, DrawOrigin.Y + Option.XAxis.AxisTick.Length + Option.XAxis.AxisTick.Distance + sfName.Height);
} }
//绘制Y轴刻度 //绘制Y轴刻度
@ -663,16 +665,16 @@ namespace Sunny.UI
for (int i = YAxisStart; i <= YAxisEnd; i++) for (int i = YAxisStart; i <= YAxisEnd; i++)
{ {
string label = Option.YAxis.AxisLabel.GetLabel(i * YAxisInterval, idx); string label = Option.YAxis.AxisLabel.GetLabel(i * YAxisInterval, idx);
SizeF sf = g.MeasureString(label, SubFont); SizeF sf = g.MeasureString(label, tmp);
wmax = Math.Max(wmax, sf.Width); wmax = Math.Max(wmax, sf.Width);
g.DrawString(label, SubFont, ChartStyle.ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f); g.DrawString(label, tmp, ChartStyle.ForeColor, DrawOrigin.X - Option.YAxis.AxisTick.Length - sf.Width, start - sf.Height / 2.0f);
start -= DrawBarHeight; start -= DrawBarHeight;
} }
SizeF sfname = g.MeasureString(Option.YAxis.Name, SubFont); SizeF sfname = g.MeasureString(Option.YAxis.Name, tmp);
int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height); int x = (int)(DrawOrigin.X - Option.YAxis.AxisTick.Length - wmax - sfname.Height);
int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2); int y = (int)(Option.Grid.Top + (DrawSize.Height - sfname.Width) / 2);
g.DrawString(Option.YAxis.Name, SubFont, ChartStyle.ForeColor, new Point(x, y), g.DrawString(Option.YAxis.Name, tmp, ChartStyle.ForeColor, new Point(x, y),
new StringFormat() { Alignment = StringAlignment.Center }, 270); new StringFormat() { Alignment = StringAlignment.Center }, 270);
} }
} }

View File

@ -169,12 +169,27 @@ namespace Sunny.UI
protected override void OnPaint(PaintEventArgs e) protected override void OnPaint(PaintEventArgs e)
{ {
base.OnPaint(e); base.OnPaint(e);
if (tip != null && !tip.Font.Equals(legendFont)) DrawOption(e.Graphics);
{
tip.Font = legendFont.DPIScaleFont();
} }
DrawOption(e.Graphics); [Category("SunnyUI")]
[DefaultValue(9)]
public float LegendFontSize { get; set; } = 9.0f;
[Category("SunnyUI")]
[DefaultValue(9)]
public float SubTextFontSize { get; set; } = 9.0f;
[Category("SunnyUI")]
[DefaultValue(9)]
public float TipsFontSize { get; set; } = 9.0f;
protected override void OnFontChanged(EventArgs e)
{
base.OnFontChanged(e);
if (tip != null)
tip.Font = this.DPIScaleFont(Font, TipsFontSize);
} }
protected virtual void DrawOption(Graphics g) protected virtual void DrawOption(Graphics g)
@ -197,33 +212,11 @@ namespace Sunny.UI
[DefaultValue(8)] [DefaultValue(8)]
public int TextInterval { get; set; } = 8; public int TextInterval { get; set; } = 8;
private Font subFont = UIFontColor.SubFont; [Browsable(false), Obsolete("已过时用SubTextFontSize代替")]
public Font SubFont { get; set; }
[DefaultValue(typeof(Font), "微软雅黑, 9pt")]
public Font SubFont
{
get => subFont;
set
{
subFont = value;
Invalidate();
}
}
private Font legendFont = UIFontColor.SubFont;
[DefaultValue(typeof(Font), "微软雅黑, 9pt")]
public Font LegendFont
{
get => legendFont;
set
{
legendFont = value;
if (tip != null) tip.Font = subFont;
Invalidate();
}
}
[Browsable(false), Obsolete("已过时用LegendFontSize代替")]
public Font LegendFont { get; set; }
protected void DrawTitle(Graphics g, UITitle title) protected void DrawTitle(Graphics g, UITitle title)
{ {
if (title == null) return; if (title == null) return;
@ -246,7 +239,7 @@ namespace Sunny.UI
g.DrawString(title.Text, Font, ChartStyle.ForeColor, left, top); g.DrawString(title.Text, Font, ChartStyle.ForeColor, left, top);
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
SizeF sfs = g.MeasureString(title.SubText, tmp); SizeF sfs = g.MeasureString(title.SubText, tmp);
switch (title.Left) switch (title.Left)
{ {
@ -273,7 +266,7 @@ namespace Sunny.UI
float maxWidth = 0; float maxWidth = 0;
float oneHeight = 0; float oneHeight = 0;
using Font tmp = LegendFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, LegendFontSize);
foreach (var data in legend.Data) foreach (var data in legend.Data)
{ {
SizeF sf = g.MeasureString(data, tmp); SizeF sf = g.MeasureString(data, tmp);

View File

@ -142,7 +142,7 @@ namespace Sunny.UI
private void DrawSeries(Graphics g, List<UIDoughnutSeries> series) private void DrawSeries(Graphics g, List<UIDoughnutSeries> series)
{ {
if (series == null || series.Count == 0) return; if (series == null || series.Count == 0) return;
using Font tmp = LegendFont.DPIScaleFont(); using Font tmp = this. DPIScaleFont(Font, LegendFontSize);
for (int pieIndex = 0; pieIndex < series.Count; pieIndex++) for (int pieIndex = 0; pieIndex < series.Count; pieIndex++)
{ {
var pie = series[pieIndex]; var pie = series[pieIndex];

View File

@ -217,7 +217,7 @@ namespace Sunny.UI
} }
if (XScale == null || YScale == null) return; if (XScale == null || YScale == null) return;
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
//X Tick //X Tick
if (Option.XAxis.AxisTick.Show) if (Option.XAxis.AxisTick.Show)
{ {
@ -534,7 +534,7 @@ namespace Sunny.UI
private void DrawAxisScales(Graphics g) private void DrawAxisScales(Graphics g)
{ {
if (YScale == null) return; if (YScale == null) return;
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
foreach (var line in Option.YAxisScaleLines) foreach (var line in Option.YAxisScaleLines)
{ {
float pos = YScale.CalcYPixel(line.Value, DrawOrigin.Y, DrawSize.Height); float pos = YScale.CalcYPixel(line.Value, DrawOrigin.Y, DrawSize.Height);
@ -669,7 +669,7 @@ namespace Sunny.UI
{ {
using (Graphics g = this.CreateGraphics()) using (Graphics g = this.CreateGraphics())
{ {
using Font tmp = SubFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, SubTextFontSize);
SizeF sf = g.MeasureString(sb.ToString(), tmp); SizeF sf = g.MeasureString(sb.ToString(), tmp);
tip.Size = new Size((int)sf.Width + 4, (int)sf.Height + 4); tip.Size = new Size((int)sf.Width + 4, (int)sf.Height + 4);
} }

View File

@ -158,7 +158,7 @@ namespace Sunny.UI
{ {
var pie = series[pieIndex]; var pie = series[pieIndex];
RectangleF rect = GetSeriesRect(pie); RectangleF rect = GetSeriesRect(pie);
using Font tmp = LegendFont.DPIScaleFont(); using Font tmp = this.DPIScaleFont(Font, LegendFontSize);
for (int azIndex = 0; azIndex < pie.Data.Count; azIndex++) for (int azIndex = 0; azIndex < pie.Data.Count; azIndex++)
{ {
Color color = ChartStyle.GetColor(azIndex); Color color = ChartStyle.GetColor(azIndex);
@ -178,7 +178,7 @@ namespace Sunny.UI
if (pie.Data[azIndex].Value > 0) if (pie.Data[azIndex].Value > 0)
{ {
string text = name + pie.Data[azIndex].Value.ToString("F0"); string text = name + pie.Data[azIndex].Value.ToString("F0");
SizeF sf = g.MeasureString(text, SubFont); SizeF sf = g.MeasureString(text, tmp);
PointF pf; PointF pf;
int added = 9; int added = 9;
if (az >= 0 && az < 90) if (az >= 0 && az < 90)
@ -191,7 +191,7 @@ namespace Sunny.UI
pf = new PointF((float)(DrawCenter(pie).X - RadiusSize(pie) * x - added) - sf.Width, (float)(DrawCenter(pie).Y - RadiusSize(pie) * y) - sf.Height - added); pf = new PointF((float)(DrawCenter(pie).X - RadiusSize(pie) * x - added) - sf.Width, (float)(DrawCenter(pie).Y - RadiusSize(pie) * y) - sf.Height - added);
if (pie.Data[azIndex].Value > 0) if (pie.Data[azIndex].Value > 0)
g.DrawString(text, SubFont, color, pf.X, pf.Y); g.DrawString(text, tmp, color, pf.X, pf.Y);
} }
} }
} }

View File

@ -326,9 +326,37 @@ namespace Sunny.UI
public static Font DPIScaleFont(this Control control, Font font) public static Font DPIScaleFont(this Control control, Font font)
{ {
if (UIStyles.DPIScale) if (UIStyles.DPIScale)
{
if (font.GdiCharSet == 134)
return new Font(font.FontFamily, font.Size / control.DPIScale(), font.Style, font.Unit, font.GdiCharSet); return new Font(font.FontFamily, font.Size / control.DPIScale(), font.Style, font.Unit, font.GdiCharSet);
else else
return font; return new Font(font.FontFamily, font.Size / control.DPIScale());
}
else
{
if (font.GdiCharSet == 134)
return new Font(font.FontFamily, font.Size, font.Style, font.Unit, font.GdiCharSet);
else
return new Font(font.FontFamily, font.Size);
}
}
public static Font DPIScaleFont(this Control control, Font font, float fontSize)
{
if (UIStyles.DPIScale)
{
if (font.GdiCharSet == 134)
return new Font(font.FontFamily, fontSize / control.DPIScale(), font.Style, font.Unit, font.GdiCharSet);
else
return new Font(font.FontFamily, fontSize / control.DPIScale());
}
else
{
if (font.GdiCharSet == 134)
return new Font(font.FontFamily, fontSize, font.Style, font.Unit, font.GdiCharSet);
else
return new Font(font.FontFamily, fontSize);
}
} }
public static Font DPIScaleFont(this Font font) public static Font DPIScaleFont(this Font font)
@ -336,8 +364,7 @@ namespace Sunny.UI
if (UIStyles.DPIScale) if (UIStyles.DPIScale)
{ {
using Control control = new(); using Control control = new();
return new Font(font.FontFamily, font.Size / control.DPIScale(), return control.DPIScaleFont(font);
font.Style, font.Unit, font.GdiCharSet);
} }
else else
{ {