Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font in 'GraphicsPath.AddString' is smaller than usual font

For some reason if I add a string to GraphicsPath using AddString the font is going to be smaller than it looks like in the Font Dialog.

  SizeF sz = g.MeasureString(Text, new Font(Font.FontFamily, (int)(Font.Size - (Font.Size / 7)), Font.Style), new PointF(0, 0), StringFormat.GenericDefault);

  this.Size = new Size((int)sz.Width, (int)sz.Height);
  //These are not the same
  fontpath.AddString(this.Text, this.Font.FontFamily,(int)this.Font.Style, this.Font.Size, new Point(0, 0),StringFormat.GenericDefault);

Does anyone know why it might be doing that?

like image 512
Kristina Brooks Avatar asked Feb 18 '10 22:02

Kristina Brooks


1 Answers

Assuming your Font.Size's unit is Point, you should convert the size that you passed to AddString to emSize (The height of the em square box that bounds the character).

float emSize = graphics.DpiY * font.Size / 72;
like image 84
idursun Avatar answered Sep 18 '22 12:09

idursun