开发者

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

For some reason if I add a string to GraphicsPath using Ad开发者_运维问答dString 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?


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;


float emSize = graphics.DpiY * font.SizeInPoints / 72;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜