Skip to content

Commit

Permalink
Merge pull request #97 from philipbelesky/feature/#81-dpi-scaling
Browse files Browse the repository at this point in the history
Feature/#81 dpi scaling
  • Loading branch information
mariuszhermansdorfer committed Jan 31, 2022
2 parents 7d0a119 + b39faff commit 472a7b4
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 472a7b4

Please sign in to comment.