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;
精彩评论