title: Distorted label text when resizing
body: <p>I have a dynamic window with labels on it. The window is a HUD and changes size depending on its parent window. However, one of the labels becomes distorted when resized. </p>
  
  <p><img src="https://i.ibb.co/L9KJqYX/label-bug.png" alt="Label bug"></p>
  
  <p>The font of the labels are resized according to the screen size like so:</p>
  
  <pre class="lang-cs prettyprint-override"><code>float fontSize = this.Width / 128 /getScalingFactor();
  </code></pre>
  
  <p>and the scaling factor is calculated as follows:</p>
  
  <pre><code>//Gets the scaling factor of the current dpi settings
          protected float getScalingFactor()
          {
              Graphics g = Graphics.FromHwnd(IntPtr.Zero);
              IntPtr desktop = g.GetHdc();
              int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
              int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);
              int logpixelsy = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSY);
              float screenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
              float dpiScalingFactor = (float)logpixelsy / (float)96;
  
              return dpiScalingFactor; // 1.25 = 125%
              //return screenScalingFactor;
          }
  </code></pre>
  
  <p>And the designer code for the labels. There are labels that holds numbers as well and they are using identical settings. However, they don't get distorted but the username label does. </p>
  
  <pre><code>this.labelUsername.AutoSize = true;
              this.tableLayoutPanel1.SetColumnSpan(this.labelUsername, 2);
              this.labelUsername.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
              this.labelUsername.ForeColor = System.Drawing.Color.White;
              this.labelUsername.Location = new System.Drawing.Point(3, 0);
              this.labelUsername.Name = "labelUsername";
              this.labelUsername.Size = new System.Drawing.Size(56, 14);
              this.labelUsername.TabIndex = 3;
              this.labelUsername.Text = "Username";
              this.labelUsername.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  </code></pre>
  
  <p>I've tried changing some numbers of the font size and scaling factor. I've tried changing some of the settings in the designer code as well. Unfortunately no success so far. </p>
  
  <p>Maybe someone recognize the issue and can point me to what causes this. I'm assuming there is some mis-match with the label and window DPI perhaps. But that doesn't explain why the numbers doesn't get the same problem.</p>