title: C# Fonts graphics: How to calculate the correct baseline position in C# to render y coordinates from Java correctly
body: <p>I get the x and y coordinates for a text from a Java backend. Now I want to draw that font in C# (Graphics.DrawString) the exact way as Java does it. For that I have to calculate the baseline. I have a code that makes it kind of right for some fonts, but is not rendered correctly for other fonts.</p>
  
  <pre><code>SizeF size = graphics.MeasureString(str, font);                                  
  int descent = font.FontFamily.GetCellDescent(font.Style);
  float factor = font.Size / font.FontFamily.GetEmHeight(font.Style);
  float leadingCalc =  (ascent * factor + descent * factor) - emHeight * factor;
  graphics.DrawString(str + "", font, brush, x, y - font.Height + descent * factor + leadingCalc);   
  </code></pre>
  
  <p>The question is, does someone know are more precise or better way to calculate the baseline?</p>