Wednesday, April 11, 2007

Calculate the string size for the specified font

Graphics g = this.CreateGraphics();
Font font = font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

SizeF textSize = g.MeasureString("sundar",font);
MessageBox.Show("Width ="+ textSize.Width + " :" + "Height :" + textSize.Height);

we can use GetTextExtentPoint32() in case of VC++...

Labels:

0 Comments:

Post a Comment

<< Home