title: Get exact height of WinForms Font in pixels
body: <p>This is possibly a duplicate question, but I am unable to find the answer.</p>
  
  <p>My only question is how to get height (ascent + descent, without any spacing) of the <code>Font</code> used in WinForms in pixels.
  I have <em>Segoe UI 8.25 Regular</em> font.</p>
  
  <p><code>Font.Height</code> gives me 15 (pixels?)</p>
  
  <p>I am able to get font metrics ans use <code>FontFamily</code>:</p>
  
  <ul>
  <li><code>GetEmHeight</code> gives me 2048.</li>
  <li><code>GetCellAscent</code> gives me 2210 (larger than EM?)</li>
  <li><code>GetCellDescent</code> gives me 514</li>
  </ul>
  
  <p>According to formula from <a href="https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-obtain-font-metrics" rel="nofollow noreferrer">MSDN</a></p>
  
  <p>I should do following:</p>
  
  <pre><code>(ascent + descent) * font.Height / emHeight
  which is
  (514 + 2210) * 15 / 2210 = 19 pixels.
  </code></pre>
  
  <p>So:</p>
  
  <ul>
  <li>Calculating using MSDN's formulas gives me <strong>19</strong>px text height.</li>
  <li><code>TextRenderer.MeasureText</code> for "Tg" string gives me <strong>13</strong>px.</li>
  <li>If a take a screenshot and measure it in Photoshop (from lowest bound of <em>g</em> to highest bound of <em>T</em>) i'll receive <strong>10</strong>px.</li>
  </ul>
  
  <p>What I'm doing wrong and how this values are interconnected? The goal is to get something as closer as possible to screenshot's measuring results.</p>
  
  <p><code>TextRenderer.MeasureText</code> uses much of resources and I can't use it anytime during draw.</p>