Font crFont = null; SizeF crSize = new SizeF(); for (int i=0 ;i<7; i++) { //set a Font object to Arial (i)pt, Bold crFont = new Font("Arial Black", sizes[i], FontStyle.Bold); //Measure the Copyright string in this Font crSize = grPhoto.MeasureString(Copyright, crFont); if((ushort)crSize.Width < (ushort)phWidth) break; }以上“arial black"是字体名称,改成相应字体名称既可,大小也一样。 代码测试通过。
http://www.codeproject.com/csharp/water.asp
SizeF crSize = new SizeF(); for (int i=0 ;i<7; i++)
{
//set a Font object to Arial (i)pt, Bold
crFont = new Font("Arial Black", sizes[i], FontStyle.Bold);
//Measure the Copyright string in this Font
crSize = grPhoto.MeasureString(Copyright, crFont); if((ushort)crSize.Width < (ushort)phWidth)
break;
}以上“arial black"是字体名称,改成相应字体名称既可,大小也一样。 代码测试通过。