Kri*_*oks 6 c# graphics fonts gdi path
出于某种原因,如果我使用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);
Run Code Online (Sandbox Code Playgroud)
有谁知道它为什么这样做?
idu*_*sun 20
假设您的Font.Size的单位是Point,您应该将传递的大小转换AddString为emSize(绑定字符的em方框的高度).
float emSize = graphics.DpiY * font.Size / 72;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5020 次 |
| 最近记录: |