title: GDI+ MesasureString() returns different size when using system font and custom font on Windows Server 2012 & Windows 10
body: <p>I have a program draw text on image by using custom fonts which are not installed in Windows System. This program works fine on Windows Server 2008 R2. Recently the program moves to Windows Server 2012 and figures the text width got by Graphics.MeasureString() function is inconsistent when using system font and custom font. The code snippet below reproduces the issue.</p>
  
  <pre><code>using (Bitmap bitmap = new Bitmap(500, 100, PixelFormat.Format24bppRgb))
  using (Graphics gfx = Graphics.FromImage(bitmap))
  {
      string text = "Measure string by using GDI+";
      float fontSize = 10.0f;
      gfx.Clear(Color.White);
      SolidBrush textBrush = new SolidBrush(Color.Black);
      PointF position = new PointF(10, 10);
  
      //Create font instance from system font
      Font systemFont = new Font("Times New Roman", fontSize, FontStyle.Bold, GraphicsUnit.World);
      //Measure the text
      SizeF systemFontTextSize = gfx.MeasureString(text, systemFont, position, StringFormat.GenericTypographic);
      gfx.DrawString(string.Format("{0}\tString width measured by system font: {1}", text, systemFontTextSize.Width), systemFont, textBrush, position);
  
      //Create custom font instance. NOTE: I just copy the Times New Roman font to a folder named after TimesNewRoman which stays on execution path.
      PrivateFontCollection pfc = new PrivateFontCollection();
      DirectoryInfo root = new DirectoryInfo(@".\TimesNewRoman");
      foreach (FileInfo fontFile in root.GetFiles("*.TTF"))
      {
          pfc.AddFontFile(fontFile.FullName);
      }
      Font customFont = new Font(pfc.Families[0], fontSize, FontStyle.Bold, GraphicsUnit.World);
  
      //Measure the text
      SizeF customFontTextSize = gfx.MeasureString(text, customFont, position, StringFormat.GenericTypographic);
      position.Y += 2 * customFont.Height;
      gfx.DrawString(string.Format("{0}\tString width measured by custom font: {1}", text, customFontTextSize.Width), systemFont, textBrush, position);
  
      bitmap.Save("FontMetrics.jpg");
  }
  </code></pre>
  
  <p>The text width of system font is 130.1514 and the text width of custom font is 127.0947. However, the width is same once drawing them the image.</p>
  
  <p>Output image:</p>
  
  <p><img src="https://i.stack.imgur.com/xaccq.png" alt="Output Image">.</p>
  
  <p>And the issue is same when I try Graphics.MeasureCharacterRanges(). 
  I'm wondering if there's any property to set to fix this issue. Thanks in advance.</p>