Skip to content

Instantly share code, notes, and snippets.

@drott
Created January 21, 2013 16:29
Show Gist options
  • Save drott/4587232 to your computer and use it in GitHub Desktop.
Save drott/4587232 to your computer and use it in GitHub Desktop.
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
for (int i = 8; i <= 30; i++)
{
FontFamily fontFamily = new FontFamily("Liberation Sans");
Font liberation = new Font(fontFamily, i, FontStyle.Regular, GraphicsUnit.Pixel);
pinvokeMapped.TEXTMETRIC liberationMetrics = pinvokeMapped.GetTextMetrics(g, liberation);
String metricsOutputString = "Liberation Sans Metrics (initialized to " + i + "px): tmAscent: " + liberationMetrics.tmAscent +
" tmDescent: " + liberationMetrics.tmDescent +
" tmHeight " + liberationMetrics.tmHeight;
// g.DrawString(metricsOutputString, liberation, System.Drawing.Brushes.Blue, new Point(30, 30));
Console.WriteLine(metricsOutputString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment