views:

228

answers:

1

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?

+2  A: 

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;
idursun