Skip to content

Commit

Permalink
Implement font DPI scaling using existing functions; closes mariuszhe…
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbelesky committed Jan 31, 2022
1 parent 7d0a119 commit b39faff
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions SandWorm/CustomComponent/WidgetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,30 @@ public static float GetScalingFactor()
float num = Screen.PrimaryScreen.LogicalPixelSize;
if ((double)num > 0.95 && (double)num < 1.05)
{
num = 1f;
num = 1f; // Windows scaling % as int; e.g. 200% = 2.0
}
return num;
}

public static int ScaleFontSize(int font_size)
{
// E.g. 8em at 100% scale; 4em at 200% scale
return (int)Math.Round((double)font_size * (double)GH_FontServer.StandardAdjusted.Height / (double)GH_FontServer.Standard.Height);
}

private WidgetServer()
{
string name = "Arial";
int num = 8;
int num = ScaleFontSize(8);
TextFont = new Font(new FontFamily(name), num, FontStyle.Regular);
string name2 = "Arial";
int num2 = 8;
int num2 = ScaleFontSize(8);
DropdownFont = new Font(new FontFamily(name2), num2, FontStyle.Italic);
string name3 = "Arial";
int num3 = 8;
int num3 = ScaleFontSize(8);
MenuHeaderFont = new Font(new FontFamily(name3), num3, FontStyle.Bold);
string name4 = "Arial";
int num4 = 10;
int num4 = ScaleFontSize(10);
SliderValueTagFont = new Font(new FontFamily(name4), num4, FontStyle.Italic);
int width = 8;
int height = 8;
Expand Down

0 comments on commit b39faff

Please sign in to comment.