“GraphicsPath.AddString”中的字体比通常的字体小
由于某种原因,如果我使用 AddString 将字符串添加到 GraphicsPath 中,字体将比字体对话框中的样子小。
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);
有人知道为什么会这样做吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的 Font.Size 单位是
Point
,您应该将传递给AddString
的大小转换为 emSize(限制字符的 em 方框的高度)。Assuming your Font.Size's unit is
Point
, you should convert the size that you passed toAddString
to emSize (The height of the em square box that bounds the character).