title: Programmatically measuring text length using GDI+ Graphics.MeasureString issue
body: <p>I have the following code that is working on my local machine (Win 7, .NET 4), but it doesn't seem to work on the server. I want to programmatically measuring text length </p>
  
  <p>Could anyone please help with it?</p>
  
  <pre><code>private float GetTextSize(string text, float textSize)
  {
      using (Bitmap bmp = new Bitmap(1, 1))
      {
          bmp.SetResolution(96, 96);
  
          using (Graphics g = Graphics.FromImage(bmp)) 
          {
              using (System.Drawing.Font font = new System.Drawing.Font(fontName, textSize))
              {
                  return g.MeasureString(text, font).Width;
              }
          }
      }
  }
  </code></pre>
  
  <p>I will consider any better solution if available.</p>
  
  <p>Update:</p>
  
  <p>How to detect if a font type is available on the machine?</p>
  
  <p>Update 2:</p>
  
  <p>Why does my question get minus points? Could anyone please give it an up vote.</p>
  
  <p>Thanks in advance!</p>