you must tell him to measure trailing spaces that are not fulfilled by default.
Graphics grfx = Graphics.FromImage(new Bitmap(1, 1)); System.Drawing.Font f = new System.Drawing.Font("Times New Roman", 10, FontStyle.Regular); string text1 = "check_space"; SizeF bounds1 = grfx.MeasureString(text1, f, new PointF(0,0), new StringFormat( StringFormatFlags.MeasureTrailingSpaces )); string text2 = "check_space "; SizeF bounds2 = grfx.MeasureString(text2, f, new PointF(0,0), new StringFormat( StringFormatFlags.MeasureTrailingSpaces ) );
source share