根据字体大小得到字符串显示时的宽度

摘要 : According to the font size displayed by the width of a string

字符串的宽度自适应容器
Graphics g = Graphics.FromImage(new Bitmap(1, 1));
SizeF size
= g.MeasureString(lblTitle.Text, new Font("宋体", 24 * 0.0625F, FontStyle.Bold));
float oldSize=(800*0.0625F);//1px=0.0625em
float newSize = (0.75F/size.Width )* oldSize;
size.Width 的单位是em
上一篇 :Sys.ArgumentOutOfRangeException: Value must be an integer
下一篇 :缇、像素、厘米的转换