gpt4 book ai didi

c# - 'GraphicsPath.AddString' 中的字体比通常的字体小

转载 作者:太空狗 更新时间:2023-10-29 20:48:01 27 4
gpt4 key购买 nike

出于某种原因,如果我使用 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);

有谁知道它为什么会这样做?

最佳答案

假设您的 Font.Size 的单位是 Point,您应该将传递给 AddString 的大小转换为 emSize(字符边界的 em 方框的高度).

float emSize = graphics.DpiY * font.Size / 72;

关于c# - 'GraphicsPath.AddString' 中的字体比通常的字体小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2292812/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com