The font in 'GraphicsPath.AddString' is smaller than the regular font

For some reason, if I add a line to GraphicsPath using AddString , the font will be smaller than what it looks in the Font dialog box.

  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 this could be?

+5
source share
2 answers

Assuming your Font.Size block is equal Point, you should convert the size you passed in AddStringto emSize (the height of the square em that borders the character).

float emSize = graphics.DpiY * font.Size / 72;
+19
source
float emSize = graphics.DpiY * font.SizeInPoints / 72;
+2
source

All Articles